Ejemplo n.º 1
0
def test_multiple_dbcon():
    """
    Expr from multiple connections to same DB should be compatible.
    """
    con1 = MockBackend()
    con2 = MockBackend()

    con1.table('alltypes').union(con2.table('alltypes')).execute()
Ejemplo n.º 2
0
    def setUp(self):
        self.con = MockBackend()
        self.table = self.con.table('functional_alltypes')

        self.i8 = self.table.tinyint_col
        self.i16 = self.table.smallint_col
        self.i32 = self.table.int_col
        self.i64 = self.table.bigint_col
        self.d = self.table.double_col
        self.f = self.table.float_col
        self.s = self.table.string_col
        self.b = self.table.bool_col
        self.t = self.table.timestamp_col
        self.dec = self.con.table('tpch_customer').c_acctbal
        self.all_cols = [
            self.i8,
            self.i16,
            self.i32,
            self.i64,
            self.d,
            self.f,
            self.dec,
            self.s,
            self.b,
            self.t,
        ]
Ejemplo n.º 3
0
    def test_ctas_ddl(self):
        con = MockBackend()

        select = ImpalaCompiler.to_ast(con.table('test1')).queries[0]
        statement = ksupport.CTASKudu(
            'another_table',
            'kudu_name',
            ['dom.d.com:7051'],
            select,
            ['string_col'],
            external=True,
            can_exist=False,
            database='foo',
        )
        result = statement.compile()

        expected = """\
CREATE EXTERNAL TABLE foo.`another_table`
TBLPROPERTIES (
  'kudu.key_columns'='string_col',
  'kudu.master_addresses'='dom.d.com:7051',
  'kudu.table_name'='kudu_name',
  'storage_handler'='com.cloudera.kudu.hive.KuduStorageHandler'
) AS
SELECT *
FROM test1"""
        assert result == expected
Ejemplo n.º 4
0
def test_multiple_db_different_backends():
    con1 = MockBackend()
    con2 = MockAlchemyBackend()

    backend1_table = con1.table('alltypes')
    backend2_table = con2.table('alltypes')

    with pytest.raises(RelationError):
        backend1_table.union(backend2_table)
Ejemplo n.º 5
0
def test_multiple_db_different_backends():
    con1 = MockBackend()
    con2 = MockAlchemyBackend()

    backend1_table = con1.table('alltypes')
    backend2_table = con2.table('alltypes')

    expr = backend1_table.union(backend2_table)
    with pytest.raises(
            ValueError,
            match=re.compile("multiple backends", flags=re.IGNORECASE),
    ):
        expr.compile()
Ejemplo n.º 6
0
 def setUp(self):
     self.con = MockBackend()
     self.name = 'test_name'
     self.inputs = ['string', 'string']
     self.output = 'int64'
Ejemplo n.º 7
0
def mockcon():
    return MockBackend()
Ejemplo n.º 8
0
def test_multiple_db():
    con1 = MockBackend()
    con2 = MockAlchemyBackend()

    con1.table('alltypes').union(con2.table('alltypes')).execute()
Ejemplo n.º 9
0
def con():
    return MockBackend()
Ejemplo n.º 10
0
 def setUp(self):
     self.con = MockBackend()
Ejemplo n.º 11
0
 def setUp(self):
     self.con = MockBackend()
     self.alltypes = self.con.table('functional_alltypes')
Ejemplo n.º 12
0
def con(request):
    return MockBackend()