def join(self, other, on=None, how='inner', hint=None): """Join this BDF to another one. `on` is `None`, `string`, `Expr`, or `list[string]` """ left = InlineView(self._query_ast.to_sql(), 'left_tbl') right = InlineView(other._query_ast.to_sql(), 'right_tbl') # SELECT left.*, right.* select_list = [SelectItem(table_name=TableName(left.name)), SelectItem(table_name=TableName(right.name))] table_ref = JoinTableRef(left, right, on=on, op=how, hint=hint) ast = SelectStmt(select_list, table_ref) return BigDataFrame(self._ic, ast)
def take(self, n): """Return `n` rows as a pandas `DataFrame` Distributed and no notion of order, so not guaranteed to be reproducible. """ alias = _random_id('inline_', 4) table_ref = InlineView(self._query_ast.to_sql(), alias) # SELECT alias.* select_list = [SelectItem(table_name=TableName(table_ref.name))] limit_elt = LimitElement(Literal(n), None) ast = SelectStmt(select_list, table_ref, limit=limit_elt) bdf = BigDataFrame(self._ic, ast) return as_pandas(bdf.__iter__())