(ОБНОВЛЕНО 3/10)
Основываясь на этой странице документации DuckDB, посвященной профилированию, я бы подумал, что мой фрагмент кода ниже должен сохранить json-файл со статистикой профилирования/времени в query_profile.json, который я смогу использовать для создания html-файла с помощью python -muckdb.query_graph query_profile.json
Однако мой код ниже (воспроизводимо, поскольку он просто попадает в общедоступную корзину s3, хотя вам потребуются ваши собственные учетные данные aws в вашем собственном файле .env) не создает такой файл query_profile.json:
import duckdb
import s3fs
from dotenv import dotenv_values
# load environment variables from .env file
ENV = dotenv_values(".env")
# Configurable query params
TAXI_COLOR = "yellow"
YEAR = 2023
PROFILE = True
# where to save result (data) locally
dbfile = 'taxi_data.duckdb'
# where to save profiling results
profile_file = 'query_profile.json'
# Define the S3 glob pattern to match the desired parquet files
s3_glob_path = f"s3://nyc-tlc/trip data/{TAXI_COLOR}_tripdata_{YEAR}*.parquet"
# query the s3 parquet data using duckdb
with duckdb.connect(database=dbfile) as con:
# load extension required for reading from s3
con.execute("INSTALL 'httpfs';")
con.execute("LOAD 'httpfs';")
# Set the AWS credentials to access the S3 bucket
con.execute("SET s3_region='us-east-1';")
con.execute(f"SET s3_access_key_id = '{ENV['AWS_ACCESS_KEY_ID']}';")
con.execute(f"SET s3_secret_access_key = '{ENV['AWS_SECRET_ACCESS_KEY']}';")
# Enable profiling and save the profiling results directly to a file
con.execute(f"SET profiling_output='{profile_file}'")
con.execute("SET profiling_mode='detailed'")
# Execute the query to load and save the data directly to the specified DuckDB file
tablename = f'{TAXI_COLOR}_tripdata_{YEAR}'
ea = "EXPLAIN ANALYZE " if PROFILE else ""
query = f"""{ea}CREATE OR REPLACE TABLE {tablename} AS
SELECT * FROM read_parquet(['{s3_glob_path}'])
"""
print(query)
con.execute(query)
print(f"Data saved to {dbfile} as {tablename}")
print(f"Profiling results saved to {profile_file}")
Подробнее здесь: https://stackoverflow.com/questions/781 ... -profiling
Почему этот запрос DuckDB к данным s3/parquet не сохраняет информацию о профилировании EXPLAIN ANALYZE? ⇐ Python
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение
-
-
Потоковая потоковая передача Polars: Parquet Parquet на основе Shift (-1)
Anonymous » » в форуме Python - 0 Ответы
- 8 Просмотры
-
Последнее сообщение Anonymous
-