zbrookle / sql_to_ibis Goto Github PK
View Code? Open in Web Editor NEWA Python package that parses sql and converts it to ibis expressions
License: BSD 3-Clause "New" or "Revised" License
A Python package that parses sql and converts it to ibis expressions
License: BSD 3-Clause "New" or "Revised" License
Queries aren't working when using != ''. Relates to zbrookle/dataframe_sql#41
I got the following error when I tried to execute the code as is
Traceback (most recent call last):
File "/Users/pavel/Projects/sql_to_ibis/mytest.py", line 1, in <module>
import ibis.pandas.api
ModuleNotFoundError: No module named 'ibis.pandas'
After I adjusted ibis packages
import ibis
import pandas
import sql_to_ibis
df = pandas.DataFrame({"column1": [1, 2, 3], "column2": ["4", "5", "6"]})
ibis_table = ibis.backends.pandas.from_dataframe(
df, name="my_table", client=ibis.backends.pandas.PandasClient({})
)
sql_to_ibis.register_temp_table(ibis_table, "my_table")
sql_to_ibis.query(
"select column1, cast(column2 as integer) + 1 as my_col2 from my_table"
).execute()
I got the following error:
Traceback (most recent call last):
File "~/miniconda3/envs/sql_to_ibis/lib/python3.9/site-packages/lark/lexer.py", line 376, in lex
for x in l.lex(stream, self.root_lexer.newline_types, self.root_lexer.ignore_types):
File "~/miniconda3/envs/sql_to_ibis/lib/python3.9/site-packages/lark/lexer.py", line 182, in lex
raise UnexpectedCharacters(stream, line_ctr.char_pos, line_ctr.line, line_ctr.column, allowed=allowed, state=self.state, token_history=last_token and [last_token])
lark.exceptions.UnexpectedCharacters: No terminal defined for 'e' at line 1 col 36
select column1, cast(column2 as integer) + 1 as my_col2 from my_table
^
Expecting: {'RPAR'}
Previous tokens: Token(TYPENAME, 'int')
Example:
select column1 as alias1, column2 as alias2, other_column1 as other_alias1, other_column2 as other_alias2
from table1 join table2
on table1.something = table2.something
where
alias1 != other_alias1 and alias2 != other_alias2
Add mypy types EVERYWHERE
Support syntax highlighting in VSCode for sql_to_ibis's "universal" SQL dialect
can you add some examples of expressions in README and/or docs?
For example "FULL\nOUTER JOIN" is valid sql but with the current grammar, it can only be "FULL\sOUTER JOIN"
Make this meta object so that things like expression / literal count are not shared
Make date function which extracts the date from an object
"SELECT * FROM mytable WHERE column1='x' AND (column2='y' OR column3='z')
works but
"SELECT * FROM mytable WHERE (column1='x' AND (column2='y' OR column3='z'))
raises InvalidQueryException
.
Sure, the outer parens around the where clause are extraneous, but the expression should still evaluate. I'm compiling where clauses from thousands of overlapping geographic features, and it is helpful as a default setting to enclose each sub-clause in parens, even if that means a lone feature ends up wrapped in these extraneous characters.
Happy to provide additional information/clarification if needed.
Drop support for python 3.6 because ibis is no longer supporting 3.6
Kindly please add support for recent ibis-framework which is compatible with recent SQLAlchemy>=1.4.
Without this, I can't use sql-to-ibis with recent SQLAlchemy, because in version 1.4 some of data types were renamed (and probably more breaking changes were introduced).
Make function to extract a certain part of a date
SELECT * FROM mytable WHERE mycolumn IN ('value1', 'value2')
works fine, but if I have more than two values within the parentheses, InvalidQueryException
is raised. The typical use of IN
should allow for n comparison values. Am I misunderstanding something in composing my query or is there a workaround for this operator to use more than two values? Thanks!
ValueError: mutable default <class 'sql_to_ibis.sql.sql_clause_objects.Preceding'> for field preceding is not allowed: use default_factory
I'm getting the above error simply importing the module, in python 3.11.5. It is the 0.4.1 release of sql_to_ibis, with ibis 3.2.0
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.