Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updatefuncs #12

Merged
merged 2 commits into from
Sep 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ pip-delete-this-directory.txt
.cache
nosetests.xml
coverage.xml
.pytest_cache

# Translations
*.mo
Expand Down
21 changes: 0 additions & 21 deletions osos/_implementations.py
Original file line number Diff line number Diff line change
Expand Up @@ -1097,27 +1097,6 @@ def raise_error_func(errMsg: Union[pd.Series, str]):






def upper_func(col: pd.Series):

if isinstance(col, str):
col = pd.Series_func(col)

return False



def lower_func(col: pd.Series):

if isinstance(col, str):
col = pd.Series_func(col)

return False



def ascii_func(col: pd.Series):

raise NotImplementedError
Expand Down
41 changes: 41 additions & 0 deletions osos/expr.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
from sqlglot import parse_one, Expression
from sqlglot.expressions import Identifier,Literal,Column,Add,Sum,Select
from collections.abc import Iterable

from osos.column import Node,AbstractCol,AbstractLit,Func,BinaryOp,UnaryOp



def print_tree(tree: Expression):
for elem in tree.walk():
node = elem[0]
print(node.args)
print("--" * node.depth, node)

def make_tree(tree: Expression) -> Node:
for elem in tree.walk():
node = elem[0]
if isinstance(node, (Identifier,Column)):
out = AbstractCol(node.name)
elif isinstance(node, Literal):
out = AbstractLit(node.name)


def main():
stmts = ["SELECT SUM(x+3)", "SELECT CASE WHEN SUM(avg(x)+2) > 3 THEN 1 ELSE 0 END",]
#stmts = ["select fo,bar from baz"]
for stmt in stmts[:1]:
s=parse_one(stmt)
print_tree(s)
#print(select_stmt.parse_string(stmt))
#print(repr(parse_one(stmt)))

#print(len(parse_one(stmt)))
...
#print(select_stmt.parse_string(stmt)[1:][0][0])
#print(stmt, "\n\t", print_tree(walk_tree(select_stmt.parse_string(stmt))))


if __name__ == '__main__':
main()

Loading
Loading