def test_ms_read(ms, group_cols, index_cols, select_cols): xds = xds_from_ms(ms, columns=select_cols, group_cols=group_cols, index_cols=index_cols, chunks={"row": 2}) order = orderby_clause(index_cols) np_column_data = [] with TableProxy(pt.table, ms, lockoptions='auto', ack=False) as T: for ds in xds: assert "ROWID" in ds.coords group_col_values = [ds.attrs[a] for a in group_cols] where = where_clause(group_cols, group_col_values) query = f"SELECT * FROM $1 {where} {order}" with TableProxy(taql_factory, query, tables=[T]) as Q: column_data = {c: Q.getcol(c).result() for c in select_cols} np_column_data.append(column_data) del T for d, (ds, column_data) in enumerate(zip(xds, np_column_data)): for c in select_cols: dask_data = ds.data_vars[c].data.compute() assert_array_equal(column_data[c], dask_data)
def ordering_taql(table_proxy, index_cols, taql_where=''): select = select_clause(["ROWID() as __tablerow__"]) orderby = "\n" + orderby_clause(index_cols) if taql_where != '': taql_where = f"\nWHERE\n\t{taql_where}" query = f"{select}\nFROM\n\t$1{taql_where}{orderby}" return TableProxy(taql_factory, query, tables=[table_proxy], __executor_key__=table_proxy.executor_key)
def ordering_taql(table_proxy, index_cols, taql_where=''): select = select_clause(["ROWID() as __tablerow__"]) orderby = "\n" + orderby_clause(index_cols) if taql_where != '': taql_where = "\nWHERE\n\t%s" % taql_where query = "%s\nFROM\n\t$1%s%s" % (select, taql_where, orderby) return TableProxy(taql_factory, query, tables=[table_proxy], __executor_key__=table_proxy.executor_key)