Exemplo n.º 1
0
 def test_udfs(self, source_tbl, udf_name, udf, is_python_udf, query,
               expected_result):
     if is_python_udf:
         register_python(udf_name, udf)
     else:
         register_numpy(udf_name, udf)
     actual_tbl = source_tbl.sql(query)
     _assert_tables_equal(actual_tbl, expected_result)
Exemplo n.º 2
0
    def test_update_udf(self, source_tbl, is_python_udf):
        def f_square(x):
            return x**2

        def f_cube(x):
            return x**3

        if is_python_udf:
            register_python('udf_upd', f_square)
            register_python('udf_upd', f_cube)
        else:
            register_python('udf_upd', f_square)
            register_python('udf_upd', f_cube)
        actual_tbl = source_tbl.sql(
            "select udf_upd(id) as pow from t order by pow")
        expected = {
            'pow': (1, 8, 27, 64, 125, 216, 343, 512),
        }
        _assert_tables_equal(actual_tbl, expected)
Exemplo n.º 3
0
 def test_from_pandas(self, input, query, expected_result):
     pdf = pd.DataFrame(data=input)
     tbl = Table.from_pandas(pdf)
     actual_tbl = tbl.sql(query)
     _assert_tables_equal(actual_tbl, expected_result)
Exemplo n.º 4
0
 def test_from_pyarrow(self, input, query, expected_result):
     arrow_table = pa.Table.from_pydict(input)
     tbl = Table.from_arrow(arrow_table)
     actual_tbl = tbl.sql(query)
     _assert_tables_equal(actual_tbl, expected_result)
Exemplo n.º 5
0
 def test_from_pydict(self, input, query, expected_result):
     actual_tbl = Table.from_pydict(input).sql(query)
     _assert_tables_equal(actual_tbl, expected_result)
Exemplo n.º 6
0
 def test_read_parquet(self, query, expected_result, parquet_datafile):
     actual_tbl = read_parquet(parquet_datafile).sql(query)
     _assert_tables_equal(actual_tbl, expected_result)
Exemplo n.º 7
0
 def test_open_csv(self, query, expected_result, csv_datafile):
     actual_tbl = stream_csv(csv_datafile).sql(query)
     _assert_tables_equal(actual_tbl, expected_result)
Exemplo n.º 8
0
 def test_queries(self, source_tbl, query, expected_result):
     actual_tbl = source_tbl.sql(query)
     _assert_tables_equal(actual_tbl, expected_result)