def get_type(expr): try: return str(expr.type()) except (AttributeError, NotImplementedError): pass try: schema = expr.schema() except (AttributeError, NotImplementedError): try: # As a last resort try get the name of the output_type class return expr.op().output_type().__name__ except (AttributeError, NotImplementedError): return '\u2205' # empty set character except com.IbisError: op = expr.op() assert isinstance(op, ops.Join) left_table_name = getattr(op.left.op(), 'name', None) or ops.genname() left_schema = op.left.schema() right_table_name = (getattr(op.right.op(), 'name', None) or ops.genname()) right_schema = op.right.schema() pairs = [(f'{left_table_name}.{left_column}', type) for left_column, type in left_schema.items() ] + [(f'{right_table_name}.{right_column}', type) for right_column, type in right_schema.items()] schema = ibis.schema(pairs) return (''.join('<BR ALIGN="LEFT" /> <I>{}</I>: {}'.format( escape(name), escape(str(type))) for name, type in zip(schema.names, schema.types)) + '<BR ALIGN="LEFT" />')
def get_type(expr): try: return str(expr.type()) except AttributeError: pass try: schema = expr.schema() except AttributeError: try: # As a last resort try get the name of the output_type class return expr.op().output_type().__name__ except AttributeError: return '\u2205' # empty set character except com.IbisError: op = expr.op() assert isinstance(op, ops.Join) left_table_name = op.left.op().name or ops.genname() left_schema = op.left.schema() right_table_name = op.right.op().name or ops.genname() right_schema = op.right.schema() pairs = [('{}.{}'.format(left_table_name, left_column), type) for left_column, type in left_schema.items() ] + [('{}.{}'.format(right_table_name, right_column), type) for right_column, type in right_schema.items()] schema = ibis.schema(pairs) return ''.join('<BR ALIGN="LEFT" /> <I>{}</I>: {}'.format(name, type) for name, type in zip(schema.names, schema.types)) + '<BR ALIGN="LEFT" />'
def get_type(expr): try: return str(expr.type()) except (AttributeError, NotImplementedError): pass try: schema = expr.schema() except (AttributeError, NotImplementedError): try: # As a last resort try get the name of the output_type class return expr.op().output_type().__name__ except (AttributeError, NotImplementedError): return '\u2205' # empty set character except com.IbisError: op = expr.op() assert isinstance(op, ops.Join) left_table_name = getattr(op.left.op(), 'name', None) or ops.genname() left_schema = op.left.schema() right_table_name = ( getattr(op.right.op(), 'name', None) or ops.genname() ) right_schema = op.right.schema() pairs = [ ('{}.{}'.format(left_table_name, left_column), type) for left_column, type in left_schema.items() ] + [ ('{}.{}'.format(right_table_name, right_column), type) for right_column, type in right_schema.items() ] schema = ibis.schema(pairs) return ( ''.join( '<BR ALIGN="LEFT" /> <I>{}</I>: {}'.format(name, type) for name, type in zip(schema.names, schema.types) ) + '<BR ALIGN="LEFT" />' )