dev
Bill 2 years ago
parent f434afbee6
commit 7945b5e65a

@ -43,7 +43,7 @@ There're multiple options to run AQuery on Windows. You can use the native toolc
- For WSL, Docker or Linux virtual machines, see Linux, Docker sections below - For WSL, Docker or Linux virtual machines, see Linux, Docker sections below
- For Visual Studio (Recommended): - For Visual Studio (Recommended):
1. Install python3.6 or above from [official website](https://www.python.org/downloads/windows/) or Microsoft Store. 1. Install python3.6 or above from [official website](https://www.python.org/downloads/windows/) or Microsoft Store.
2. Install Microsoft Visual Studio 2022 or later with **Desktop development with C++** selected. 2. Install Microsoft Visual Studio 2022 or later with **Desktop development with C++** selected.
3. Clone AQuery repo from [Github](https://github.com/sunyinqi0508/AQuery2) 3. Clone AQuery repo from [Github](https://github.com/sunyinqi0508/AQuery2)
4. Install python requirements with pip `python3 -m pip install -r requirements.txt` 4. Install python requirements with pip `python3 -m pip install -r requirements.txt`
@ -108,7 +108,7 @@ There're multiple options to run AQuery on Windows. You can use the native toolc
`f moving_avg.a` <br> `f moving_avg.a` <br>
`xexec` `xexec`
See ./tests/ for more examples. See files in ./tests/ for more examples.
## Automated Testing Scripts ## Automated Testing Scripts
- A series of commands can be put in a script file and execute using `script` command. - A series of commands can be put in a script file and execute using `script` command.
@ -174,4 +174,4 @@ See ./tests/ for more examples.
- [x] Functionality: Basic helper functions in aquery - [x] Functionality: Basic helper functions in aquery
- [ ] Bug: Join-Aware Column management - [ ] Bug: Join-Aware Column management
- [ ] Bug: Order By after Group By - [ ] Bug: Order By after Group By
- [ ] Functionality: Having clause - [ ] Functionality: Having clause, With clause

@ -672,13 +672,15 @@ def parser(literal_string, ident, sqlserver=False):
module_func_def = ( module_func_def = (
var_name("fname") var_name("fname")
+ LB + LB
+ delimited_list( + Optional(
delimited_list(
( (
var_name("arg") var_name("arg")
+ COLON + COLON
+ var_name("type") + var_name("type")
)("vars") )("vars")
) )
)
+ RB + RB
+ LAMBDA + LAMBDA
+ var_name("ret_type") + var_name("ret_type")

@ -98,7 +98,7 @@ FloatT = Types(16, name = 'float', cname = 'float', sqlname = 'REAL',
HgeT = Types(9, name = 'int128',cname='__int128_t', sqlname = 'HUGEINT', fp_type = DoubleT) HgeT = Types(9, name = 'int128',cname='__int128_t', sqlname = 'HUGEINT', fp_type = DoubleT)
UHgeT = Types(10, name = 'uint128', cname='__uint128_t', sqlname = 'HUGEINT', fp_type = DoubleT) UHgeT = Types(10, name = 'uint128', cname='__uint128_t', sqlname = 'HUGEINT', fp_type = DoubleT)
LongT = Types(4, name = 'int64', sqlname = 'BIGINT', fp_type = DoubleT) LongT = Types(4, name = 'int64', sqlname = 'BIGINT', fp_type = DoubleT)
BoolT = Types(0, name = 'bool', sqlname = 'BOOL', long_type=LongT, fp_type=FloatT) BoolT = Types(0, name = 'bool', cname='bool', sqlname = 'BOOL', long_type=LongT, fp_type=FloatT)
ByteT = Types(1, name = 'int8', sqlname = 'TINYINT', long_type=LongT, fp_type=FloatT) ByteT = Types(1, name = 'int8', sqlname = 'TINYINT', long_type=LongT, fp_type=FloatT)
ShortT = Types(2, name = 'int16', sqlname='SMALLINT', long_type=LongT, fp_type=FloatT) ShortT = Types(2, name = 'int16', sqlname='SMALLINT', long_type=LongT, fp_type=FloatT)
IntT = Types(3, name = 'int', cname = 'int', long_type=LongT, fp_type=FloatT) IntT = Types(3, name = 'int', cname = 'int', long_type=LongT, fp_type=FloatT)

@ -558,7 +558,7 @@ def prompt(running = lambda:True, next = lambda:input('> '), state = None):
state.stmts = parser.parse(og_q.strip()) state.stmts = parser.parse(og_q.strip())
cxt.Info(state.stmts) cxt.Info(state.stmts)
state.currstats.parse_time = state.currstats.stop() state.currstats.parse_time = state.currstats.stop()
except ParseException as e: except (ParseException, KeyError) as e:
print(e) print(e)
continue continue
except (ValueError, FileNotFoundError) as e: except (ValueError, FileNotFoundError) as e:
@ -574,9 +574,15 @@ def prompt(running = lambda:True, next = lambda:input('> '), state = None):
raise raise
except ValueError as e: except ValueError as e:
import code, traceback import code, traceback
__stdin = os.dup(0)
raise_exception = True raise_exception = True
sh = code.InteractiveConsole({**globals(), **locals()}) sh = code.InteractiveConsole({**globals(), **locals()})
try:
sh.interact(banner = traceback.format_exc(), exitmsg = 'debugging session ended.') sh.interact(banner = traceback.format_exc(), exitmsg = 'debugging session ended.')
except:
pass
finally:
sys.stdin = io.TextIOWrapper(io.BufferedReader(io.FileIO(__stdin, mode='rb', closefd=False)), encoding='utf8')
save('', cxt) save('', cxt)
rm(state) rm(state)
# control whether to raise exception in interactive console # control whether to raise exception in interactive console

@ -916,7 +916,7 @@ class insert(ast_node):
# raise ValueError("Column Mismatch") # raise ValueError("Column Mismatch")
list_values = [] list_values = []
for i, s in enumerate(values): for i, s in enumerate(enlist(values)):
if 'value' in s: if 'value' in s:
list_values.append(f"{s['value']}") list_values.append(f"{s['value']}")
else: else:

@ -86,11 +86,26 @@ __AQEXPORT__(void) init_session(Context* cxt);
#else #else
void* memcpy(void*, const void*, unsigned long long); void* memcpy(void*, const void*, unsigned long long);
#endif #endif
struct vectortype_storage{
void* container = nullptr;
unsigned int size = 0, capacity = 0;
vectortype_storage(void* container, unsigned int size, unsigned int capacity) :
container(container), size(size), capacity(capacity) {}
vectortype_storage() = default;
template <class Ty, template <typename> class VT>
vectortype_storage(const VT<Ty>& vt) {
memcpy(this, &vt, sizeof(vectortype_storage));
}
};
struct ColRef_storage { struct ColRef_storage {
void* container; void* container = nullptr;
unsigned int capacity, size; unsigned int size = 0, capacity = 0;
const char* name; const char* name = nullptr;
int ty; // what if enum is not int? int ty = 0; // what if enum is not int?
ColRef_storage(void* container, unsigned int size, unsigned int capacity, const char* name, int ty) :
container(container), size(size), capacity(capacity), name(name), ty(ty) {}
ColRef_storage() = default;
template <class Ty, template <typename> class VT> template <class Ty, template <typename> class VT>
ColRef_storage(const VT<Ty>& vt) { ColRef_storage(const VT<Ty>& vt) {
memcpy(this, &vt, sizeof(ColRef_storage)); memcpy(this, &vt, sizeof(ColRef_storage));

@ -0,0 +1,25 @@
LOAD MODULE FROM "./libirf.so"
FUNCTIONS (
mydiv(a:int, b:int) -> double,
mulvec(a:int, b:vecfloat) -> vecfloat,
newtree(height:int, f:int64, sparse:vecint, forget:double, maxF:int64, noClasses:int64, e:int, r:int64, rb:int64) -> bool,
additem(X:vecdouble, y:int64, size:int64) -> bool,
fit() -> bool,
predict() -> vecint
);
select mydiv(2,3);
create table tb(x int);
create table tb2(x double, y double, z double);
insert into tb values (0);
insert into tb values (0);
insert into tb values (0);
select newtree(5, 3, tb.x, 0, 3, 2, 0, 100, 1) from tb;
insert into tb2 values (1, 0, 1);
insert into tb2 values (0, 1, 1);
insert into tb2 values (1, 1, 1);
select additem(tb2.x, 1, 3) from tb2;
select additem(tb2.y, 0, -1) from tb2;
select additem(tb2.z, 1, -1) from tb2;
select fit();
select predict();
Loading…
Cancel
Save