Esempio n. 1
0
    def _get_udfs(self, cur, klass):
        from ibis.expr.rules import varargs
        from ibis.expr.datatypes import validate_type

        def _to_type(x):
            ibis_type = udf._impala_type_to_ibis(x.lower())
            return validate_type(ibis_type)

        tuples = cur.fetchall()
        if len(tuples) > 0:
            result = []
            for out_type, sig in tuples:
                name, types = _split_signature(sig)
                types = _type_parser(types).types

                inputs = []
                for arg in types:
                    argm = _arg_type.match(arg)
                    var, simple = argm.groups()
                    if simple:
                        t = _to_type(simple)
                        inputs.append(t)
                    else:
                        t = _to_type(var)
                        inputs = varargs(t)
                        # TODO
                        # inputs.append(varargs(t))
                        break

                output = udf._impala_type_to_ibis(out_type.lower())
                result.append(klass(inputs, output, name=name))
            return result
        else:
            return []
Esempio n. 2
0
    def _get_udfs(self, cur, klass):
        from ibis.expr.rules import varargs
        from ibis.expr.datatypes import validate_type

        def _to_type(x):
            ibis_type = udf._impala_type_to_ibis(x.lower())
            return validate_type(ibis_type)

        tuples = cur.fetchall()
        if len(tuples) > 0:
            result = []
            for out_type, sig in tuples:
                name, types = _split_signature(sig)
                types = _type_parser(types).types

                inputs = []
                for arg in types:
                    argm = _arg_type.match(arg)
                    var, simple = argm.groups()
                    if simple:
                        t = _to_type(simple)
                        inputs.append(t)
                    else:
                        t = _to_type(var)
                        inputs = varargs(t)
                        # TODO
                        # inputs.append(varargs(t))
                        break

                output = udf._impala_type_to_ibis(out_type.lower())
                result.append(klass(inputs, output, name=name))
            return result
        else:
            return []
Esempio n. 3
0
 def _get_udfs(self, cur):
     tuples = cur.fetchall()
     if len(tuples) > 0:
         regex = re.compile("^.*?\((.*)\).*")
         result = []
         for out_type, sig in tuples:
             name = sig.split('(')[0]
             inputs = self._parse_input_string(regex.findall(sig)[0])
             output = udf._impala_type_to_ibis(out_type.lower())
             result.append(udf.UDFInfo(inputs, output, name))
         return result
     else:
         return []
Esempio n. 4
0
 def _get_udfs(self, cur):
     tuples = cur.fetchall()
     if len(tuples) > 0:
         regex = re.compile("^.*?\((.*)\).*")
         result = []
         for out_type, sig in tuples:
             name = sig.split('(')[0]
             inputs = self._parse_input_string(regex.findall(sig)[0])
             output = udf._impala_type_to_ibis(out_type.lower())
             result.append(udf.UDFInfo(inputs, output, name))
         return result
     else:
         return []
Esempio n. 5
0
 def _parse_input_string(self, s):
     regex = re.compile(r'(?:[^,(]|\([^)]*\))+')
     results = regex.findall(s)
     return [udf._impala_type_to_ibis(x.strip().lower())
             for x in results]
Esempio n. 6
0
 def _parse_input_string(self, s):
     regex = re.compile(r'(?:[^,(]|\([^)]*\))+')
     results = regex.findall(s)
     return [udf._impala_type_to_ibis(x.strip().lower()) for x in results]
Esempio n. 7
0
 def _to_type(x):
     ibis_type = udf._impala_type_to_ibis(x.lower())
     return validate_type(ibis_type)
Esempio n. 8
0
 def _to_type(x):
     ibis_type = udf._impala_type_to_ibis(x.lower())
     return validate_type(ibis_type)