Preql
Preql copied to clipboard
Assertion error with BigQuery when running .pql scripts but not REPL
Running the following (or any other) script with preql -m foo
command:
connect("bigquery:///gcp-project-id-here")
cal = import_table("test_data.temp_cal")
print(cal)
Results in the correct execution (judging by the output) but an assertion error afterwards. Doing the same in REPL works without any errors.
(INFO) state -- [Preql] Connecting to bigquery:///gcp-project-id-here
table temp_cal =5
┏━━━━━━━━━━┳━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Fin_Year ┃ Fin_Year_Label ┃ id ┃
┡━━━━━━━━━━╇━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ 2016 │ FY16 │ 1849f81a-51c6-4135-ac16-120d2e5a92fd │
│ 2016 │ FY16 │ bf20059c-7089-4b7b-a0df-a583d3a7fad9 │
│ 2016 │ FY16 │ 158140c2-9228-49a2-90e6-a44aafd7f9c5 │
│ 2016 │ FY16 │ ea7f8b5b-8f80-4b56-9f97-4cdd5a26105a │
│ 2016 │ FY16 │ 9b6abcc5-6da7-4d9d-923b-84e7d33e311e │
└──────────┴────────────────┴──────────────────────────────────────┘
Traceback (most recent call last):
File "/PyCharmVenv/PreQL/bin/preql", line 8, in <module>
sys.exit(main())
File "/PyCharmVenv/PreQL/lib/python3.9/site-packages/preql/__main__.py", line 76, in main
p('import ' + args.module)
File "/PyCharmVenv/PreQL/lib/python3.9/site-packages/preql/api.py", line 25, in inner
return f(*args, **kwargs)
File "/PyCharmVenv/PreQL/lib/python3.9/site-packages/preql/api.py", line 197, in __call__
res = self._run_code(code, '<inline>', args)
File "/PyCharmVenv/PreQL/lib/python3.9/site-packages/preql/api.py", line 193, in _run_code
return self._interp.execute_code(code + "\n", source_name, pql_args)
File "/PyCharmVenv/PreQL/lib/python3.9/site-packages/preql/core/interpreter.py", line 36, in inner
return f(interp, *args, **kwargs)
File "/PyCharmVenv/PreQL/lib/python3.9/site-packages/preql/core/interpreter.py", line 86, in _execute_code
last = execute(stmt)
File "/PyCharmVenv/PreQL/lib/python3.9/site-packages/preql/core/evaluate.py", line 383, in execute
return stmt._execute() or objects.null
File "/PyCharmVenv/PreQL/lib/python3.9/site-packages/preql/core/evaluate.py", line 364, in _execute
module = import_module(context.state, r)
File "/PyCharmVenv/PreQL/lib/python3.9/site-packages/preql/core/evaluate.py", line 355, in import_module
assert state.db is i.state.db
AssertionError
Yes, my bad, sorry!
I pushed a fix to the schemas
branch.