Skip to content
This repository was archived by the owner on May 9, 2024. It is now read-only.

Add working pyhdk example -- to readme? #24

Closed
alexbaden opened this issue May 17, 2022 · 0 comments
Closed

Add working pyhdk example -- to readme? #24

alexbaden opened this issue May 17, 2022 · 0 comments
Labels
documentation Improvements or additions to documentation

Comments

@alexbaden
Copy link
Contributor

e.g.:

import pyhdk
storage = pyhdk.storage.ArrowStorage(1) # 1 is schema id
data_mgr = pyhdk.storage.DataMgr()
data_mgr.registerDataProvider(storage)

calcite = pyhdk.sql.Calcite(storage)
executor = pyhdk.Executor(data_mgr)

import pyarrow
import pandas
at = pyarrow.Table.from_pandas(
            pandas.DataFrame({"a": [1, 2, 3], "b": [10, 20, 30]})
        )
opt = pyhdk.storage.TableOptions(2)
storage.importArrowTable(at, "test", opt)

sql = "SELECT * FROM test;"
ra = calcite.process(sql)
rel_alg_executor = pyhdk.sql.RelAlgExecutor(executor, storage, data_mgr, ra)
print(rel_alg_executor.execute().to_arrow().to_pandas())

print(rel_alg_executor.execute(just_explain = True).to_explain_str())

@alexbaden alexbaden added the documentation Improvements or additions to documentation label May 17, 2022
alexbaden added a commit that referenced this issue Sep 19, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

1 participant