def translate(): """ :return: """ from ibis.omniscidb.compiler import OmniSciDBDialect dialect = OmniSciDBDialect() context = dialect.make_context() return lambda expr: dialect.translator(expr, context).get_result()
def translate() -> typing.Callable: """Create a translator function. Returns ------- function """ from ibis.omniscidb.compiler import OmniSciDBDialect dialect = OmniSciDBDialect() context = dialect.make_context() return lambda expr: dialect.translator(expr, context).get_result()
def create_table(self, table_name, obj=None, schema=None, database=None, max_rows=None): """ Create a new table in OmniSciDB using an Ibis table expression. Parameters ---------- table_name : string obj : TableExpr or pandas.DataFrame, optional If passed, creates table from select statement results schema : ibis.Schema, optional Mutually exclusive with expr, creates an empty table with a particular schema database : string, default None (optional) max_rows : int, Default None Set the maximum number of rows allowed in a table to create a capped collection. When this limit is reached, the oldest fragment is removed. Default = 2^62. Examples -------- >>> con.create_table('new_table_name', table_expr) # doctest: +SKIP """ _database = self.db_name self.set_database(database) if obj is not None: if isinstance(obj, pd.DataFrame): raise NotImplementedError( 'Pandas Data Frame input not implemented.') else: to_insert = obj ast = self._build_ast(to_insert, OmniSciDBDialect.make_context()) select = ast.queries[0] statement = ddl.CTAS(table_name, select, database=database) elif schema is not None: statement = ddl.CreateTableWithSchema(table_name, schema, database=database, max_rows=max_rows) else: raise com.IbisError('Must pass expr or schema') result = self._execute(statement, False) self.set_database(_database) return result
def create_view(self, name, expr, database=None): """ Create an OmniSciDB view from a table expression Parameters ---------- name : string expr : ibis TableExpr database : string, default None """ ast = self._build_ast(expr, OmniSciDBDialect.make_context()) select = ast.queries[0] statement = ddl.CreateView(name, select, database=database) self._execute(statement)
def create_table( self, table_name: str, obj: Optional[Union[ir.TableExpr, pd.DataFrame]] = None, schema: Optional[sch.Schema] = None, database: Optional[str] = None, max_rows: Optional[int] = None, fragment_size: Optional[int] = None, is_temporary: bool = False, **kwargs, ): """ Create a new table from an Ibis table expression. Parameters ---------- table_name : string obj : ibis.expr.types.TableExpr or pandas.DataFrame, optional If passed, creates table from select statement results schema : ibis.Schema, optional table_name : str obj : TableExpr or pandas.DataFrame, optional, default None If passed, creates table from select statement results. schema : ibis.Schema, optional, default None Mutually exclusive with expr, creates an empty table with a particular schema database : str, optional, default None max_rows : int, optional, default None Set the maximum number of rows allowed in a table to create a capped collection. When this limit is reached, the oldest fragment is removed. fragment_size: int, optional, default 32000000 if gpu_device is enabled otherwise 5000000 Number of rows per fragment that is a unit of the table for query processing, which is not expected to be changed. is_temporary : bool, default False If True it the table will be created as temporary. Examples -------- >>> con.create_table('new_table_name', table_expr) # doctest: +SKIP """ _database = self.db_name self.set_database(database) if fragment_size is None: fragment_size = 32000000 if self.gpu_device else 5000000 if obj is not None: if isinstance(obj, pd.DataFrame): raise NotImplementedError( 'Pandas Data Frame input not implemented.') else: to_insert = obj ast = self._build_ast(to_insert, OmniSciDBDialect.make_context()) select = ast.queries[0] statement = ddl.CTAS(table_name, select, database=database) elif schema is not None: statement = ddl.CreateTableWithSchema( table_name, schema, database=database, max_rows=max_rows, fragment_size=fragment_size, is_temporary=is_temporary, ) else: raise com.IbisError('Must pass expr or schema') self._execute(statement, False) self.set_database(_database)