Skip to content

Can connect to in memory duckdb #63

Description

@ivanonair

I want to connect to the MINIO on the local host through DuckDB to compare the two Parquet files. I intend to use the in-memory mode to connect to MINIO directly, rather than loading the Parquet files into a DuckDB persistence file first and then using reladiff for comparison.

Currently, this works in Python:

import pandas as pd
import duckdb
from data_diff import connect_to_table ,diff_tables

con = duckdb.connect('local_test.duckdb',config={"allow_unsigned_extensions": "true"})
con.load_extension('httpfs')
con.execute('''
    SET s3_region='local';
    SET s3_url_style='path';
    SET s3_endpoint=' minio endpoint here';
    SET s3_access_key_id=' id here' ;
    SET s3_secret_access_key=' key here ';)
con.execute("""CREATE or replace TABLE fa as (SELECT * FROM read_parquet('s3://*/fa.parquet'))""")
con.execute("""CREATE or replace TABLE fa1 as (SELECT * FROM read_parquet('s3://*/fa.parquet') LIMIT 2)  """)
df = con.execute("""SELECT * FROM fa """).df()
df1 = con.execute("""SELECT * FROM fa1 """).df()
con.close()

source = connect_to_table(db_info= {"driver":"duckdb", "filepath": "local_test.duckdb"},table_name="fa",key_columns=["CO_CD","MAIN_ASSET_NO"])
target = connect_to_table(db_info= {"driver":"duckdb", "filepath": "local_test.duckdb"},table_name="fa2",key_columns=["CO_CD","MAIN_ASSET_NO"])

diff_result = diff_tables(source,target,)
diff_df = pd.DataFrame(diff_result)

But if I change to

source = connect_to_table(db_info= {"duckdb:///:memory:"},table_name="fa",key_columns=["CO_CD","MAIN_ASSET_NO"])

I got error as below:
IOException: IO Error: Cannot open file "/:memory:": Permission denied

I'm considering whether we can first create an in-memory DuckDB connection and directly pass the connection to Reladiff.

Thanks!!

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions