示例#1
0
    def test_sql_generation_from_infoclass(self):
        func = api.wrap_udf('test.so', ['string'], 'string', 'info_test')
        repr(func)

        func.register('info_test', 'udf_testing')
        result = func('hello world')
        assert result == "SELECT udf_testing.info_test('hello world')"
示例#2
0
    def test_sql_generation_from_infoclass(self):
        func = api.wrap_udf('test.so', ['string'], 'string', 'info_test')
        repr(func)

        func.register('info_test', 'udf_testing')
        result = func('hello world')
        assert result == "SELECT udf_testing.info_test('hello world')"
示例#3
0
文件: test_udf.py 项目: zdog234/ibis
 def test_create_udf(self):
     func = api.wrap_udf('/foo/bar.so', self.inputs, self.output,
                         so_symbol='testFunc', name=self.name)
     stmt = ddl.CreateUDF(func)
     result = stmt.compile()
     expected = ("CREATE FUNCTION `test_name`(string, string) "
                 "returns bigint "
                 "location '/foo/bar.so' symbol='testFunc'")
     assert result == expected
示例#4
0
    def _udf_creation_to_op(self, name, symbol, inputs, output):
        func = api.wrap_udf(self.udf_ll, inputs, output, symbol, name)

        self.temp_udfs.append((name, inputs))

        self.con.create_function(func, database=self.test_data_db)

        func.register(name, self.test_data_db)

        assert self.con.exists_udf(name, self.test_data_db)
        return func
示例#5
0
    def _udf_creation_to_op(self, name, symbol, inputs, output):
        func = api.wrap_udf(self.udf_ll, inputs, output, symbol, name)

        self.temp_udfs.append((name, inputs))

        self.con.create_function(func, database=self.test_data_db)

        func.register(name, self.test_data_db)

        assert self.con.exists_udf(name, self.test_data_db)
        return func
示例#6
0
def udf_creation_to_op(udf_ll, udfcon, test_data_db, name, symbol, inputs,
                       output):
    func = api.wrap_udf(udf_ll, inputs, output, symbol, name)

    # self.temp_udfs.append((name, inputs))

    udfcon.create_function(func, database=test_data_db)

    func.register(name, test_data_db)

    assert udfcon.exists_udf(name, test_data_db)
    return func
示例#7
0
def test_udf_varargs(udfcon, alltypes, udf_ll, test_data_db):
    t = alltypes

    name = 'add_numbers_{0}'.format(util.guid()[:4])

    input_sig = rules.varargs(rules.double)
    func = api.wrap_udf(udf_ll, input_sig, 'double', 'AddNumbers', name=name)
    func.register(name, test_data_db)
    udfcon.create_function(func, database=test_data_db)

    expr = func(t.double_col, t.double_col)
    expr.execute()
示例#8
0
文件: test_udf.py 项目: cloudera/ibis
def test_udf_varargs(udfcon, alltypes, udf_ll, test_data_db):
    t = alltypes

    name = 'add_numbers_{0}'.format(util.guid()[:4])

    input_sig = rules.varargs(rules.double)
    func = api.wrap_udf(udf_ll, input_sig, 'double', 'AddNumbers', name=name)
    func.register(name, test_data_db)
    udfcon.create_function(func, database=test_data_db)

    expr = func(t.double_col, t.double_col)
    expr.execute()
示例#9
0
文件: test_udf.py 项目: cloudera/ibis
def udf_creation_to_op(
    udf_ll, udfcon, test_data_db, name, symbol, inputs, output
):
    func = api.wrap_udf(udf_ll, inputs, output, symbol, name)

    # self.temp_udfs.append((name, inputs))

    udfcon.create_function(func, database=test_data_db)

    func.register(name, test_data_db)

    assert udfcon.exists_udf(name, test_data_db)
    return func
示例#10
0
def test_drop_database_with_udfs_and_udas(udfcon, temp_database,
                                          wrapped_count_uda):
    uda1 = wrapped_count_uda

    udf1 = api.wrap_udf(udf_ll, ['boolean'], 'boolean', 'Identity',
                        'udf_{0}'.format(util.guid()))

    db = temp_database

    udfcon.create_database(db)

    udfcon.create_function(uda1, database=db)
    udfcon.create_function(udf1, database=db)
示例#11
0
文件: test_udf.py 项目: zdog234/ibis
    def test_create_udf_type_conversions(self):
        inputs = ['string', 'int8', 'int16', 'int32']
        func = api.wrap_udf('/foo/bar.so', inputs, self.output,
                            so_symbol='testFunc', name=self.name)
        stmt = ddl.CreateUDF(func)

        # stmt = ddl.CreateFunction('/foo/bar.so', 'testFunc',
        #                           ,
        #                           self.output, self.name)
        result = stmt.compile()
        expected = ("CREATE FUNCTION `test_name`(string, tinyint, "
                    "smallint, int) returns bigint "
                    "location '/foo/bar.so' symbol='testFunc'")
        assert result == expected
示例#12
0
文件: test_udf.py 项目: cloudera/ibis
 def test_create_udf(self):
     func = api.wrap_udf(
         '/foo/bar.so',
         self.inputs,
         self.output,
         so_symbol='testFunc',
         name=self.name,
     )
     stmt = ddl.CreateUDF(func)
     result = stmt.compile()
     expected = (
         "CREATE FUNCTION `test_name`(string, string) "
         "returns bigint "
         "location '/foo/bar.so' symbol='testFunc'"
     )
     assert result == expected
示例#13
0
    def test_drop_database_with_udfs_and_udas(self):
        uda1 = self._wrap_count_uda()
        uda2 = self._wrap_count_uda()

        udf1 = api.wrap_udf(self.udf_ll, ['boolean'], 'boolean', 'Identity',
                            'udf_{0}'.format(util.guid()))

        db = '__ibis_tmp_{0}'.format(util.guid())

        self.con.create_database(db)

        self.con.create_function(uda1, database=db)
        self.con.create_function(uda2, database=db)

        self.con.create_function(udf1, database=db)

        self.con.drop_database(db, force=True)

        assert not self.con.exists_database(db)
示例#14
0
    def test_drop_database_with_udfs_and_udas(self):
        uda1 = self._wrap_count_uda()
        uda2 = self._wrap_count_uda()

        udf1 = api.wrap_udf(self.udf_ll, ['boolean'], 'boolean', 'Identity',
                            'udf_{0}'.format(util.guid()))

        db = '__ibis_tmp_{0}'.format(util.guid())

        self.con.create_database(db)

        self.con.create_function(uda1, database=db)
        self.con.create_function(uda2, database=db)

        self.con.create_function(udf1, database=db)

        self.con.drop_database(db, force=True)

        assert not self.con.exists_database(db)
示例#15
0
文件: test_udf.py 项目: cloudera/ibis
def test_drop_database_with_udfs_and_udas(
    udfcon, temp_database, wrapped_count_uda
):
    uda1 = wrapped_count_uda

    udf1 = api.wrap_udf(
        udf_ll,
        ['boolean'],
        'boolean',
        'Identity',
        'udf_{0}'.format(util.guid()),
    )

    db = temp_database

    udfcon.create_database(db)

    udfcon.create_function(uda1, database=db)
    udfcon.create_function(udf1, database=db)
示例#16
0
文件: test_udf.py 项目: cloudera/ibis
    def test_create_udf_type_conversions(self):
        inputs = ['string', 'int8', 'int16', 'int32']
        func = api.wrap_udf(
            '/foo/bar.so',
            inputs,
            self.output,
            so_symbol='testFunc',
            name=self.name,
        )
        stmt = ddl.CreateUDF(func)

        # stmt = ddl.CreateFunction('/foo/bar.so', 'testFunc',
        #                           ,
        #                           self.output, self.name)
        result = stmt.compile()
        expected = (
            "CREATE FUNCTION `test_name`(string, tinyint, "
            "smallint, int) returns bigint "
            "location '/foo/bar.so' symbol='testFunc'"
        )
        assert result == expected