我已经从数据库中创建了一个具有三列(id、author、title)的parquet文件,并希望使用条件(title='learnpython')读取拼花板文件。
下面提到的是我用于这个POC的python代码。在import pyarrow as pa
import pyarrow.parquet as pq
import pandas as pd
import pyodbc
def write_to_parquet(df, out_path, compression='SNAPPY'):
arrow_table = pa.Table.from_pandas(df)
if compression == 'UNCOMPRESSED':
compression = None
pq.write_table(arrow_table, out_path, use_dictionary=False,
compression=compression)
def read_pyarrow(path, nthreads=1):
return pq.read_table(path, nthreads=nthreads).to_pandas()
path = './test.parquet'
sql = "SELECT * FROM [dbo].[Book] (NOLOCK)"
conn = pyodbc.connect(r'Driver={SQL
Server};Server=.;Database=APP_BBG_RECN;Trusted_Connection=yes;')
df = pd.io.sql.read_sql(sql, conn)
write_to_parquet(df, path)
df1 = read_pyarrow(path)
如何将条件(title='learnpython')放入read_pyarrow方法中?在