BigQuery:bq load命令是否支持从命名管道加载作为源?

时间:2015-07-11 02:59:11

标签: linux google-bigquery

我正在尝试使用命名管道中的var arr = []; var obj = {}; obj.order_id = 1; obj.name = "Cake"; obj.price = "1 Dollar"; obj.qty = 1; arr.push(obj); localStorage.setItem('buy',JSON.stringify(arr)); 将数据加载到Google bigquery。

控制台窗口1:

bq load

控制台窗口2:

 $ mkfifo /usr/pipe1
 $ cat /dev1/item.dat > /usr/pipe1

出现以下错误:

 $ bq load --source_format=CSV  projectid:dataset.itemtbl /usr/pipe1 field1:integer,field2:integer

2 个答案:

答案 0 :(得分:3)

BigQuery客户端bq.py不支持命名管道。它明确要求文件:

https://code.google.com/p/google-bigquery-tools/source/browse/bq/bigquery_client.py?r=30df4638ff2ddb01d3f495af5c131ed3c2cfbd04#617

允许命名管道是一个很好的功能建议。你可以在这里索取:

https://code.google.com/p/google-bigquery/issues/list

看起来您可以很容易地调整bigquery_client.py的副本以使其也能正常工作。祝你好运!

答案 1 :(得分:-1)

bq load命令不支持管道文件。 这是您更改代码以绕过管道文件验证时的错误。

== Error trace ==
Traceback (most recent call last):
  File "/usr/local/share/google/google-cloud-sdk/platform/bq/bq.py", line 1001, in RunSafely
    return_value = self.RunWithArgs(*args, **kwds)
  File "/usr/local/share/google/google-cloud-sdk/platform/bq/bq.py", line 1355, in RunWithArgs
    job = client.Load(table_reference, source, schema=schema, **opts)
  File "/usr/local/share/google/google-cloud-sdk/platform/bq/bigquery_client.py", line 3504, in Load
    upload_file=upload_file, **kwds)
  File "/usr/local/share/google/google-cloud-sdk/platform/bq/bigquery_client.py", line 2924, in ExecuteJob
    location=location)
  File "/usr/local/share/google/google-cloud-sdk/platform/bq/bigquery_client.py", line 2901, in RunJobSynchronously
    location=location)
  File "/usr/local/share/google/google-cloud-sdk/platform/bq/bigquery_client.py", line 2755, in StartJob
    resumable=resumable)
  File "/usr/local/share/google/google-cloud-sdk/platform/bq/third_party/oauth2client_4_0/_helpers.py", line 134, in positional_wrapper
    return wrapped(*args, **kwargs)
  File "/usr/local/share/google/google-cloud-sdk/platform/bq/third_party/googleapiclient/http.py", line 562, in __init__
    resumable=resumable)
  File "/usr/local/share/google/google-cloud-sdk/platform/bq/third_party/oauth2client_4_0/_helpers.py", line 134, in positional_wrapper
    return wrapped(*args, **kwargs)
  File "/usr/local/share/google/google-cloud-sdk/platform/bq/third_party/googleapiclient/http.py", line 439, in __init__
    self._fd.seek(0, os.SEEK_END)
IOError: [Errno 29] Illegal seek
========================================

Unexpected exception in load operation: You have encountered a bug in the
BigQuery CLI. Please file a bug report in our
public issue tracker:
https://issuetracker.google.com/issues/new?component=187149&template=0
Please include a brief description of the steps that led to this issue, as well
as any rows that can be made public from the following information:
Hora : 2018-10-05 10:04:02