[英]Not able to run spoon.bat or any other batch file in Pentaho Data Integration (Kettle)
[英]BIGQUERY - How to create a connection with Pentaho Data Integration (Spoon)?
我试图通过Pentaho数据集成访问BigQuery,但我没有成功。
我已经按照本教程使用了OSX http://wiki.pentaho.com/display/EAI/Google+BigQuery
这就是我所做的:
我按照本教程https://code.google.com/p/starschema-bigquery-jdbc/wiki/JDBCURL配置了此参数的连接。 所以参数是:
jdbc:BQDriver:projectid(secretproject)?withServiceAccount=true
net.starschema.clouddb.jdbc.BQDrive
pentaho-data-integration@secretproject.iam.gserviceaccount.com
我不知道的事情:
有人能帮助我吗?
这是我尝试测试创建的连接时的日志:
连接到数据库时出错[Teste]:org.pentaho.di.core.exception.KettleDatabaseException:尝试连接数据库时出错
找不到驱动程序类'net.starschema.clouddb.jdbc.BQDrive',请确保已安装'通用数据库'驱动程序(jar文件)。 net.starschema.clouddb.jdbc.BQDrive
org.pentaho.di.core.exception.KettleDatabaseException:尝试连接数据库时发生错误
找不到驱动程序类'net.starschema.clouddb.jdbc.BQDrive',请确保已安装'通用数据库'驱动程序(jar文件)。 net.starschema.clouddb.jdbc.BQDrive
org.pentaho.di.core.database.Database.normalConnect(Database.java:428)位于org.pentaho.di.core的org.pentaho.di.core.database.Database.connect(Database.java:358)位于org.pentaho.di.core.database.DatabaseFactory.getConnectionTestReport(DatabaseFactory)的org.pentaho.di.core.database.Database.connect(Database.java:301)的.database.Database.connect(Database.java:311) .java:80)在org.pentaho.di.core.database.DatabaseMeta.testConnection(DatabaseMeta.java:2686)org.pentaho.ui.database.event.DataHandler.testDatabaseConnection(DataHandler.java:546)at sun。在sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)的sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)的java.lang.reflect.Method.invoke上的reflect.NativeMethodAccessorImpl.invoke0(Native Method)方法.java:597)org.pentaho.ui.xul.impl.AbstractXulDomContainer.invoke(AbstractXulDomContainer.java:313)org.pentaho.ui.xul.impl.AbstractXulComponent.invoke(AbstractXulComponen) t.java:157)org.pentaho.ui.xul.impl.AbstractXulComponent.invoke(AbstractXulComponent.java:141)org.pentaho.ui.xul.swt.tags.SwtButton.access $ 500(SwtButton.java:43 )org.pentaho.ui.xul.swt.tags.SwtButton $ 4.widgetSelected(SwtButton.java:138)位于org.eclipse.swt.widgets的org.eclipse.swt.widgets.TypedListener.handleEvent(未知来源)。位于org.eclipse.swt.widgets.Widget的org.eclipse.swt.widgets.Widget.sendEvent(未知来源)的org.eclipse.swt.widgets.Display.sendEvent(未知来源)的EventTable.sendEvent(未知来源)。在org.eclipse.swt.wts.widget上的org.eclipse.swt.wts.widget.sendLentners(未知来源)的org.eclipse.swt.widgets.Widget.sendEvent(未知来源)的sendEvent(未知来源)(在org.eclipse.swt.wts.widgets.Dunplay.runDeferredEvents上)未知来源)org.eclipse.wt上的org.eclipse.wts.widge.Dindplay.readAndDvent(orn.e.ef.::::: or or or or or or or or or or or or or or or or or or or or or or or or or or or or or or or or or or or or or (Window.java:796)org.pentaho.ui.xul.swt.tags.SwtDialog.show(SwtDialog) .java:389)org.pentaho.ui.xul.swt.tags.SwtDialog.show(SwtDialog.java:318)org.pentaho.di.ui.core.database.dialog.XulDatabaseDialog.open(XulDatabaseDialog.java) :116)org.pentaho.di.ui.core.database.dialog.DatabaseDialog.open(DatabaseDialog.java:59)at org.pentaho.di.ui.spoon.delegates.SpoonDBDelegate.newConnection(SpoonDBDelegate.java:464) )在org.pentaho.di.ui.spoon.delegates.SpoonDBDelegate.newConnection(SpoonDBDelegate.java:451)org.pentaho.di.ui.spoon.Spoon.newConnection(Spoon.java:8728)at sun.reflect。 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)中的NativeMethodAccessorImpl.invoke0(Native Method)位于sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)at java.lang.reflect.Method.invoke(Method。 java:597)org.pentah.ui.xul.impl.AbstractXulDomContainer.invoke(AbstractXulDomContainer.java:313)atg.pentaho.ui.xul.impl.AbstractXulComponent.invoke(AbstractXulComponent.java:157)atg.pentaho .ui.xul.impl.Abst ractXulComponent.invoke(AbstractXulComponent.java:141)org.pentaho.ui.xul.jface.tags.JfaceMenuitem.access $ 100(JfaceMenuitem.java:43)org.pentaho.ui.xul.jface.tags.JfaceMenuitem $ 1。运行(JfaceMenuitem.java:106)org.eclipse.jface.action.Action.runWithEvent(Action.java:498)org.eclipse.action.AdctionContributionItem.handleWidgetSelection(ActionContributionItem.java:545)org.eclipse .gface.action.ActionContributionItem.access $ 2(ActionContributionItem.java:490)org.eclipse.action.ActionContributionItem $ 5.handleEvent(ActionContributionItem.java:402)org.eclipse.swt.widgets.EventTable.sendEvent(Unknown)来自org.eclipse.swt.wt.widget.sendEvent(未知来源)org.eclipse.swt.widgets.Wind.sendEvent(未知来源)org.eclipse.swt.widgets.Widget.sendEvent(未知来源)位于org.eclipse.swt.wts.widget上的org.eclipse.swt.wts.widget.sendLentners(未知来源)org.eclipse.swt.wt.Uwt. 在org.pentaho.di.ui.ui.ui.spoon的org.pentaho.di.ui.spoon.Spoon.readAndDispatch(Spoon.java:1319)org.eclipse.swt.widgets.Display.readAndDispatch(未知来源)的nknown Source .spoon.waitForDispose(Spoon.java:7939)atg.pentaho.di.ui.spoon.Spoon.start(Spoon.java:9190)at org.pentaho.di.ui.spoon.Spoon.main(Spoon.java) :654)at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)at java.lang。反射.Method.invoke(Method.java:597)atg.pentaho.commons.launcher.Launcher.main(Launcher.java:92)at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at sun.reflect.NativeMethodAccessorImpl。在apple.launcher.LaunchRunner.run(LaunchRu)的java.lang.reflect.Method.invoke(Method.java:597)的sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)中调用(NativeMethodAccessorImpl.java:39) nner.java:116)at apple.launcher.LaunchRunner.callMain(LaunchRunner.java:51)at apple.launcher.JavaApplicationLauncher.launch(JavaApplicationLauncher.java:52)引起:org.pentaho.di.core.exception.KettleDatabaseException :找不到驱动程序类'net.starschema.clouddb.jdbc.BQDrive',请确保已安装'通用数据库'驱动程序(jar文件)。 net.starschema.clouddb.jdbc.BQDrive
org.pentaho.di.core.database.Database.connectUsingClass(Database.java:522)位于org.pentaho.di.core的org.pentaho.di.core.database.Database.connectUsingClass(Database.java:4697) .database.Database.normalConnect(Database.java:414)... 70更多引起:java.lang.ClassNotFoundException:net.net.URLClassLoader $ 1.run中的net.starschema.clouddb.jdbc.BQDrive(URLClassLoader.java: 202)java.security.AccessController.doPrivileged(Native Method)at java.net.URLClassLoader.findClass(URLClassLoader.java:190)at java.lang.ClassLoader.loadClass(ClassLoader.java:306)at java.lang.ClassLoader .loadClass(ClassLoader.java:247)org.pentaho.di.core.database.Database.connectUsingClass(Database.java:497)... 72更多
自定义网址 :
jdbc:BQDriver:projectid(secretproject)?withServiceAccount = true自定义驱动程序类:net.starschema.clouddb.jdbc.BQDrive
答案可能不会让你高兴,但我们走了。 可以创建这种连接,但是提取有问题并且行的流量非常慢(Bigquery可以快速处理任何内容,但是这种JDBC使得获取数据的速度非常慢。
我在这里做的是一个Python 2.7脚本,用于将查询提取到表中并将表提取到Google Cloud Storage上的csv文件,然后下载该文件。
这真的很快,你不会有很多错误。
这里是你可以使用的python代码。 (您需要安装google storage utils才能轻松地将文件从云端复制到您的机器上)
SH代码:( 在JOB上的shell脚本条目中使用)
#!/bin/bash
export PATH=${PATH}
# BOTO is the login manager for GsUtil
export BOTO_DISPLAYENV="/home/mromano/.boto"
export BOTO_CONFIG="/home/mromano/.boto"
rm /tmp/bigquery_extraction_*
#Run Big Query extraction script on python
python "$caminho/google_bigquery_extract_foo_bar.py"
#Give it some seconds to sync data to Google Cloud Storage
sleep 10
#Copy from Google Cloud Storage to local file
/usr/local/bin/gsutil -q cp gs://pentaho_exports/google_bigquery_extract_foo_bar.csv.gz /tmp/google_bigquery_extract_foo_bar.csv.gz
python脚本:( 创建一个包含查询结果的表,将表导出为CSV并删除表)
import httplib2
import logging
logging.basicConfig()
from apiclient.discovery import build
from oauth2client.client import SignedJwtAssertionCredentials
from bigquery import get_client
# BigQuery project id as listed in the Google Developers Console.
project_id = 'ce______?_____8'
# Service account email address as listed in the Google Developers Console.
service_account = '5399951_____?_______73k@developer.gserviceaccount.com'
f = file('../../../../keys/bigquery_key.p12', 'rb')
key = f.read()
f.close()
credentials = SignedJwtAssertionCredentials(
service_account,
key,
scope='https://www.googleapis.com/auth/bigquery')
http = httplib2.Http()
http = credentials.authorize(http)
client = get_client(project_id, credentials=credentials, service_account=service_account)
# Write to table
job = client.write_to_table("""SELECT * FROM 001234.TEST""",
'pentaho_export',
table='table_foo_bar',
create_disposition='CREATE_IF_NEEDED',
write_disposition='WRITE_TRUNCATE')
try:
job_resource = client.wait_for_job(job, timeout=6000)
#print job_resource
except BigQueryTimeoutException:
print "Timeout"
# Exporting
job_export = client.export_data_to_uris( ['gs://pentaho_exports/foo_bar.csv.gz'],
'pentaho_export',
'table_foo_bar',
compression='GZIP',
field_delimiter=' ')
try:
job_resource = client.wait_for_job(job_export, timeout=6000)
#print job_resource
except BigQueryTimeoutException:
print "Timeout"
# Delete an existing table.
deleted = client.delete_table('pentaho_export', 'table_foo_bar')
我希望它有所帮助。 =)
确保您已完成以下操作。
你说,
2)我下载并将“bqjdbc-1.4-standalone.jar”复制到PDI_FOLDER / lib
它也应该复制到data-integration\\libext\\JDBC
。 如果没有这样的文件夹,则需要创建它并复制.jar
文件。
然后自定义连接URL应如下所示:
jdbc:BQDriver:themetic-scope-114043?withServiceAccount=true
其中themetic-scope-114043
是您的项目ID。 (使用正确的ID)
自定义驱动程序类名称错误(最后遗漏的信件)
net.starschema.clouddb.jdbc.BQDriver
密码应正确指向.p12文件。 在我的Windows机器上,我使用C:\\ Digin-f537871c3b66.p12作为密码,物理文件应该在上述路径中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.