minor bug fixes

This commit is contained in:
2022-01-22 02:31:35 -05:00
parent ee2dc88f06
commit 137d670da2
7 changed files with 49 additions and 33 deletions
+7 -1
View File
@@ -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'):
+21 -9
View File
@@ -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
+3 -1
View File
@@ -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):