From 137d670da2451875585b7748f05566620496cace Mon Sep 17 00:00:00 2001 From: Bill Sun Date: Sat, 22 Jan 2022 02:31:35 -0500 Subject: [PATCH] minor bug fixes --- aquery_parser/sql_parser.py | 12 ------------ csv.so | Bin 0 -> 43512 bytes engine/ast.py | 8 +++++++- engine/expr.py | 30 +++++++++++++++++++++--------- engine/projection.py | 4 +++- moving_avg.csv | 12 ++++++------ run.py | 16 ++++++++++++---- 7 files changed, 49 insertions(+), 33 deletions(-) create mode 100644 csv.so diff --git a/aquery_parser/sql_parser.py b/aquery_parser/sql_parser.py index e24479b..fe0ebd9 100644 --- a/aquery_parser/sql_parser.py +++ b/aquery_parser/sql_parser.py @@ -16,18 +16,6 @@ from aquery_parser.types import get_column_type, time_functions from aquery_parser.utils import * from aquery_parser.windows import window - -def no_dashes(tokens, start, string): - if "-" in tokens[0]: - index = tokens[0].find("-") - raise ParseException( - tokens.type, - start + index + 1, # +1 TO ENSURE THIS MESSAGE HAS PRIORITY - string, - """Ambiguity: Use backticks (``) around identifiers with dashes, or add space around subtraction operator.""", - ) - - digit = Char("0123456789") simple_ident = ( Char(FIRST_IDENT_CHAR) diff --git a/csv.so b/csv.so new file mode 100644 index 0000000000000000000000000000000000000000..5c230b8ecfac366797c6dac931eaa5d6b0948836 GIT binary patch literal 43512 zcmeFa2UJs8)G(S*6cD_CC>Csp3MvYA6of#6Hy9KJ?21ZJ#0m+;MlcC*jTf;Y_TGC# zMS%cHQ>kJvh%F(4fJzne?{kwNP4{Zx^cq9>XI$;{-b-ZbbY zL9nRVh2Bk6Wz^ntMxDnH5090tALovYH~2~n(`xMk%~XF~c%o%G!k_UVQIR1nim&4& z=$FH#(NLQK{Gra>au$C|QVbca|LNf2mApB$6=8E|eJ(XR=>)!7UO0XC29Kq&oos6- zIP`h6N;?4Bgp!{fJ`XLCXAWO!48#BNgK+5g4=qcf?wfIHd=KoMX5(sw`W|C}CHkwgNOr!0FqA{&AZHr3(ROW+r2LMI= z%eE=|Z&uA21y3Vd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-JaV5)xCECeWC`sVS-v4eFX!)-MtU0Y zhT+No?C+;kuK!lP0uKC>jR)Bgo(U!^yYTgJww$cYZLR+=r*?k6y6b4jPpmPIHaxoU zxSYpu9=GzC&SL?O7kTX7J}QS7pxl3t{$0sFKC+So68C{bhX1Nx@~`awpPas>nb`zg zJ$tuce@U?J2t)BGvEi^0!Ls6rbt4VMhNFk@WbEHq$ICg#bz_y0F-#of9V7{qxVm9t z{{V@n*vmgyygV>qxo4mxvooE_3As_}ubk5=`vl?*soKEA|TDGeMs2m{{T&0>vdz4cq}9t`b)`nZnz7 zNuaBrr?a;Qw1!IZHk@4p16@H`P6FkjD_1`sXbhU>x&SR@?YIR6VPf|HKR-`@?xMv1 zLgK;*7ei3o$>uW%b-VR};tL}G4w3oJ8drkl|t|l1Fh9 zp&`$R^hbOM9ig6!$*7FtGD2fszPtWB8S{b+*EW(z?*jD*uL;L&%-> z+%+NpL9`2y5y1=XgV4ULj{hZkcY7gugf~I9XBT<2Z)@S@5g)L~5-KCC0xIXbsDHGN zXy@fGa)X0}_IXGS=@kWa91D^!KFV>!HE?cXAWfIUKmQ|ngmqBURURwgS<~g{%@+|M zIfRW+(N!MpL&DSL68(7nk-RR-@YoE~6 b+jpZQ`L2li?#lWlLtgsPl?Ztxhsgf`hA7LH literal 0 HcmV?d00001 diff --git a/engine/ast.py b/engine/ast.py index 40d6782..aa23aef 100644 --- a/engine/ast.py +++ b/engine/ast.py @@ -1,6 +1,12 @@ from typing import List -import uuid +# replace column info with this later. +class ColRef: + def __init__(self, k9name, type, cobj, cnt): + self.k9name = k9name + self.type = type + self.cobj = cobj + self.cnt = cnt class TableInfo: def __init__(self, table_name, cols, cxt:'Context'): diff --git a/engine/expr.py b/engine/expr.py index 3722a3b..adf0819 100644 --- a/engine/expr.py +++ b/engine/expr.py @@ -4,12 +4,23 @@ from engine.ast import ast_node class expr(ast_node): name='expr' builtin_func_maps = { - 'max': 'max', - 'min': 'min', + 'max': 'max', + 'min': 'min', + 'avg':'avg', + 'sum':'sum', - } - binary_ops = {'sub':'-', 'plus':'+'} - unary_ops = [] + } + binary_ops = { + 'sub':'-', + 'add':'+', + 'mul':'*', + 'div':'%', + + } + unary_ops = { + 'neg' : '-', + + } def __init__(self, parent, node): from engine.projection import projection if type(parent) in [projection, expr]: @@ -29,18 +40,19 @@ class expr(ast_node): # if type(val) in [dict, str]: self.k9expr += expr(self, val).k9expr - self.k9expr+=')' + self.k9expr += ')' elif key in self.binary_ops: l = expr(self, val[0]).k9expr r = expr(self, val[1]).k9expr self.k9expr += f'({l}{self.binary_ops[key]}{r})' - print(f'binary{key}') elif key in self.unary_ops: - print(f'unary{key}') + self.k9expr += f'({expr(self, val).k9expr}{self.unary_ops[key]})' else: - print(key) + print(f'Undefined expr: {key}{val}') elif type(node) is str: self.k9expr = self.datasource.parse_tablenames(node) + else: + self.k9expr = f'{node}' def __str__(self): return self.k9expr \ No newline at end of file diff --git a/engine/projection.py b/engine/projection.py index 3e444b7..40d02b8 100644 --- a/engine/projection.py +++ b/engine/projection.py @@ -47,7 +47,9 @@ class projection(ast_node): if self.datasource is None: raise ValueError('spawn error: from clause') - + if 'where' in node: + # apply filter + pass def consume(self, node): diff --git a/moving_avg.csv b/moving_avg.csv index e304cc2..f6b2570 100644 --- a/moving_avg.csv +++ b/moving_avg.csv @@ -1,6 +1,6 @@ -Month sales -1 100 -2 120 -4 140 -3 140 -5 130 +Month,sales +1,100 +2,120 +4,140 +3,140 +5,130 diff --git a/run.py b/run.py index afec3cc..09db800 100644 --- a/run.py +++ b/run.py @@ -1,3 +1,4 @@ +from multiprocessing.sharedctypes import Value import re import aquery_parser as parser import engine @@ -18,11 +19,18 @@ while test_parser: q = input() if q == 'exec': cxt = engine.initialize() - for s in stmts['stmts']: - engine.generate(s, cxt) + stmts_stmts = stmts['stmts'] + if type(stmts_stmts) is list: + for s in stmts_stmts: + engine.generate(s, cxt) + else: + engine.generate(stmts_stmts, cxt) print(cxt.k9code) with open('out.k', 'wb') as outfile: - outfile.write(cxt.k9code) + outfile.write(cxt.k9code.encode('utf-8')) + continue + elif q == 'print': + print(stmts) continue trimed = ws.sub(' ', q.lower()).split(' ') if trimed[0] == 'file': @@ -35,6 +43,6 @@ while test_parser: continue stmts = parser.parse(q) print(stmts) - except Exception as e: + except ValueError as e: print(type(e), e)