【问题标题】:parquet to hyper conversion using pyspark使用 pyspark 将 parquet 转换为超级转换
【发布时间】:2022-09-25 11:17:33
【问题描述】:

我想使用 python 将镶木地板文件转换为超文件格式。为此有以下 git - https://github.com/tableau/hyper-api-samples/blob/main/Community-Supported/parquet-to-hyper/create_hyper_file_from_parquet.py。但在这种情况下,镶木地板格式 /schema 是事先已知的。如果我想让它适用于任何 parquet 文件,我应该怎么做,而不管模式如何。

我也想不使用熊猫,而是使用 pyspark 来完成它。 Pandas 会使处理大文件的速度变慢。

    标签: python pyspark parquet


    【解决方案1】:

    如果您不想在从 parquet 文件创建 .hyper 文件时定义模式,您可以使用 CREATE TABLE 命令而不是 COPY 命令。

    要使用CREATE TABLE 命令,您可以像这样跳过架构和表定义:

        # Start the Hyper process.
        with HyperProcess(telemetry=Telemetry.SEND_USAGE_DATA_TO_TABLEAU) as hyper:
    
            # Open a connection to the Hyper process. This will also create the new Hyper file.
            # The `CREATE_AND_REPLACE` mode causes the file to be replaced if it
            # already exists.
            with Connection(endpoint=hyper.endpoint,
                            database=hyper_database_path,
                            create_mode=CreateMode.CREATE_AND_REPLACE) as connection:
                            
                            connection.execute_command("CREATE TABLE products AS (SELECT * FROM external('products.parquet'))")
    

    【讨论】:

      猜你喜欢
      • 2018-12-15
      • 1970-01-01
      • 1970-01-01
      • 2017-11-08
      • 1970-01-01
      • 1970-01-01
      • 2019-07-05
      • 1970-01-01
      相关资源
      最近更新 更多