Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: can't mutate and then drop #1296

Closed
tsdlovell opened this issue Jan 24, 2018 · 0 comments
Closed

BUG: can't mutate and then drop #1296

tsdlovell opened this issue Jan 24, 2018 · 0 comments
Assignees
Labels
bug Incorrect behavior inside of ibis
Milestone

Comments

@tsdlovell
Copy link

On current master

git log | head -n 3
commit 5cafaee7369403a261b3e5df2ddb0c9968aa85f9
Author: Phillip Cloud <cpcloud@gmail.com>
Date:   Wed Jan 24 08:44:17 2018 -0500

I can't do table.mutate(b=table.a).drop(['a'])

In [1]: import ibis

In [2]: import pandas as pd

In [3]: client = ibis.pandas.connect({
   ...:         'df': pd.DataFrame({'a': [1, 2, 3]}),
   ...:         'df_unknown': pd.DataFrame({
   ...:             'array_of_strings': [['a', 'b'], [], ['c']],
   ...:         }),
   ...:     })
   ...:     

In [4]: table = client.table('df')

In [5]: table.mutate(b=table.a).drop(['a'])
---------------------------------------------------------------------------
IbisTypeError                             Traceback (most recent call last)
<ipython-input-5-2f4c8dc18c5a> in <module>()
----> 1 table.mutate(b=table.a).drop(['a'])

/nas/dft/ire/dlovell/gitlab/ibis/ibis/expr/api.py in _table_drop(self, fields)
   2829         raise KeyError('Fields not in table: {0!s}'.format(fields))
   2830 
-> 2831     return self.projection(to_project)
   2832 
   2833 

/nas/dft/ire/dlovell/gitlab/ibis/ibis/expr/api.py in projection(table, exprs)
   2760     projector = L.Projector(table, exprs)
   2761 
-> 2762     op = projector.get_result()
   2763     return TableExpr(op)
   2764 

/nas/dft/ire/dlovell/gitlab/ibis/ibis/expr/analysis.py in get_result(self)
    761 
    762         if len(roots) == 1 and isinstance(roots[0], ops.Selection):
--> 763             fused_op = self._check_fusion(roots[0])
    764             if fused_op is not None:
    765                 return fused_op

/nas/dft/ire/dlovell/gitlab/ibis/ibis/expr/analysis.py in _check_fusion(self, root)
    773         can_fuse = False
    774 
--> 775         resolved = _maybe_resolve_exprs(root.table, self.input_exprs)
    776         if not resolved:
    777             return None

/nas/dft/ire/dlovell/gitlab/ibis/ibis/expr/analysis.py in _maybe_resolve_exprs(table, exprs)
    820 def _maybe_resolve_exprs(table, exprs):
    821     try:
--> 822         return table._resolve(exprs)
    823     except AttributeError:
    824         return None

/nas/dft/ire/dlovell/gitlab/ibis/ibis/expr/types.py in _resolve(self, exprs)
    797         out_exprs = []
    798         for expr in exprs:
--> 799             expr = self._ensure_expr(expr)
    800             out_exprs.append(expr)
    801         return out_exprs

/nas/dft/ire/dlovell/gitlab/ibis/ibis/expr/types.py in _ensure_expr(self, expr)
    803     def _ensure_expr(self, expr):
    804         if isinstance(expr, six.string_types):
--> 805             return self[expr]
    806         elif isinstance(expr, six.integer_types):
    807             return self[self.schema().name_at_position(expr)]

/nas/dft/ire/dlovell/gitlab/ibis/ibis/expr/types.py in __getitem__(self, what)
    728     def __getitem__(self, what):
    729         if isinstance(what, six.string_types + six.integer_types):
--> 730             return self.get_column(what)
    731 
    732         if isinstance(what, slice):

/nas/dft/ire/dlovell/gitlab/ibis/ibis/expr/types.py in get_column(self, name)
    846         column : array expression
    847         """
--> 848         ref = TableColumn(name, self)
    849         return ref.to_expr()
    850 

/nas/dft/ire/dlovell/gitlab/ibis/ibis/expr/types.py in __init__(self, name, table_expr)
    423         if name not in schema:
    424             raise com.IbisTypeError(
--> 425                 "'{0}' is not a field in {1}".format(name, table_expr.columns)
    426             )
    427 

IbisTypeError: 'b' is not a field in ['a']
@cpcloud cpcloud changed the title can't mutate and then drop BUG: can't mutate and then drop Jan 24, 2018
@cpcloud cpcloud self-assigned this Jan 24, 2018
@cpcloud cpcloud added the bug Incorrect behavior inside of ibis label Jan 24, 2018
@cpcloud cpcloud added this to the 0.13 milestone Jan 24, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Incorrect behavior inside of ibis
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants