【问题标题】:GCP Cloud Functions to BigQuery - parquet support errorGCP Cloud Functions 到 BigQuery - parquet 支持错误
【发布时间】:2020-06-19 20:29:56
【问题描述】:

我正在尝试运行一个简单的测试cloud function,在其中创建一个BigQuery 表并插入一个值。我收到的错误听起来像是我需要导入pyarrow,所以我试过这样做,但我一直收到同样的错误。当我在本地运行等效脚本时,没有任何问题,表已创建,我什至不需要导入pyarrow。我在这里想念什么?

error

ImportError: Unable to find a usable engine; tried using: 'pyarrow', 'fastparquet'. pyarrow or fastparquet is required for parquet support

main.py:

import pandas as pd
from google.cloud import bigquery
import pyarrow

def main_func(data, context):
    df = pd.DataFrame({'Test': ['Success']})

    client = bigquery.Client()

    dataset_id = #removed here but specified in the real code
    dataset = bigquery.Dataset(dataset_id)
    dataset.location = #removed here but specified in the real code
    dataset = client.create_dataset(dataset, exists_ok=True)
    print("Created dataset {}.{}".format(client.project, dataset.dataset_id))

    table_id = #removed here but specified in the real code

    job_config = bigquery.LoadJobConfig(
        schema=[
            bigquery.SchemaField("Test", bigquery.enums.SqlTypeNames.STRING),
        ],
        write_disposition="WRITE_TRUNCATE",
    )

    job = client.load_table_from_dataframe(
        df, table_id, job_config = job_config
    )

    job.result()

requirements.txt:

pandas
google-cloud-bigquery
pyarrow

【问题讨论】:

  • 我发现Pandas由于兼容性问题没有检测到任何pyarrow<0.4,你可以尝试在你的requirements.txt中添加pyarrow>=0.4
  • 老兄!刚刚试过,效果很好!添加一个答案,我会接受它!谢谢:)

标签: python pandas google-cloud-platform google-bigquery google-cloud-functions


【解决方案1】:

您的 pyarrow 版本有问题。由于兼容性问题,Pandas 没有检测到任何pyarrow<0.4,因此您应该尝试在您的requirements.txt 中添加pyarrow>=0.4

Pyarrow is not properly detected after importing ray

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-01-07
    • 2018-12-03
    • 2019-03-25
    • 2021-09-15
    • 1970-01-01
    • 2019-12-01
    • 2021-09-02
    • 2018-06-11
    相关资源
    最近更新 更多