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 []
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 []
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 []
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 []
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]
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]
def _to_type(x): ibis_type = udf._impala_type_to_ibis(x.lower()) return validate_type(ibis_type)
def _to_type(x): ibis_type = udf._impala_type_to_ibis(x.lower()) return validate_type(ibis_type)