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

table.head() throws AttributeError: 'float' object has no attribute 'toArray' #412

Closed
HuifangYeo opened this issue Nov 19, 2021 · 0 comments
Labels
🐛 bug unexpected or wrong behavior
Milestone

Comments

@HuifangYeo
Copy link
Contributor

Steps to reproduce

The below table has a DOUBLE_ARRAY:

sales = session.read_pandas(
    sales_df.drop("product_name", axis=1),
    keys=["prod_id", "date"],
    table_name="sales",
    types={
        "predicted_sales": tt.type.NULLABLE_DOUBLE_ARRAY,
        "sales": tt.type.NULLABLE_DOUBLE,
    },
)

When we run sales.head(), it throws the error: AttributeError: 'float' object has no attribute 'toArray'

Environment

  • atoti: 0.6.3
  • Python: 3.8.12
  • Operating System: win32

Logs (if relevant)

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
C:\Users\YEOHUI~1\AppData\Local\Temp/ipykernel_49732/3841596795.py in 
----> 1 sales.head()

C:\Apps\miniconda3\envs\ds\lib\site-packages\atoti_type_utils.py in typechecked_func_wrapper(*args, **kwargs)
184
185 # Call the actual function.
--> 186 return self._func(*args, **kwargs)
187
188 # Mark the function as typechecked and return it.

C:\Apps\miniconda3\envs\ds\lib\site-packages\atoti_docs_utils.py in wrapper(*args, **kwargs)
14 @wraps(func)
15 def wrapper(*args: Any, **kwargs: Any) -> Callable[..., Any]:
---> 16 return func(*args, **kwargs)
17
18 # Collecting docstring and docstring templates

C:\Apps\miniconda3\envs\ds\lib\site-packages\atoti\table.py in head(self, n)
244 raise ValueError("n must be at least 1.")
245
--> 246 return self._java_api.get_table_dataframe(
247 self, n, scenario_name=self.scenario, keys=self.keys
248 )

C:\Apps\miniconda3\envs\ds\lib\site-packages\atoti\exceptions.py in catch_py4j_exceptions(java_api, *args, **kwargs)
69 def catch_py4j_exceptions(java_api: JavaApi, *args: Any, **kwargs: Any) -> Any:
70 try:
---> 71 return method(java_api, *args, **kwargs)
72 except Py4JJavaError as java_exception:
73 cause = (

C:\Apps\miniconda3\envs\ds\lib\site-packages\atoti_java_api.py in get_table_dataframe(self, table, rows, keys, scenario_name)
667 dataframe[name] = dataframe[name].apply(to_date)
668 if is_array(data_type):
--> 669 dataframe[name] = dataframe[name].apply(to_python_list)
670
671 if keys:

C:\Apps\miniconda3\envs\ds\lib\site-packages\pandas\core\series.py in apply(self, func, convert_dtype, args, **kwargs)
4355 dtype: float64
4356 """
-> 4357 return SeriesApply(self, func, convert_dtype, args, kwargs).apply()
4358
4359 def _reduce(

C:\Apps\miniconda3\envs\ds\lib\site-packages\pandas\core\apply.py in apply(self)
1041 return self.apply_str()
1042
-> 1043 return self.apply_standard()
1044
1045 def agg(self):

C:\Apps\miniconda3\envs\ds\lib\site-packages\pandas\core\apply.py in apply_standard(self)
1096 # List[Union[Callable[..., Any], str]]]]]"; expected
1097 # "Callable[[Any], Any]"
-> 1098 mapped = lib.map_infer(
1099 values,
1100 f, # type: ignore[arg-type]

C:\Apps\miniconda3\envs\ds\lib\site-packages\pandas_libs\lib.pyx in pandas._libs.lib.map_infer()

C:\Apps\miniconda3\envs\ds\lib\site-packages\atoti_py4j_utils.py in to_python_list(list_to_convert)
142 """Convert a Java list to a Python list."""
143 # ignore types when calling a Java function
--> 144 return list(list_to_convert.toArray()) # type: ignore

AttributeError: 'float' object has no attribute 'toArray'


server.log

@HuifangYeo HuifangYeo added the 🐛 bug unexpected or wrong behavior label Nov 19, 2021
HuifangYeo added a commit to atoti/notebooks that referenced this issue Nov 19, 2021
@bloussou bloussou self-assigned this Nov 19, 2021
@bloussou bloussou added this to the Next release milestone Nov 19, 2021
HuifangYeo added a commit to atoti/notebooks that referenced this issue Nov 23, 2021
* Update to atoti 0.6.3

* Update poetry.lock

* Update poetry for black

* Commented `table.head()` for table with double array (atoti/atoti#412)

* Update screen captures on top count notebook

* Commented Twitter notebook for atoti/atoti#412

* Updated XVA to use session.link()

- updated endpoint url for KPI
- use ZipFile (for windows compatibility)

* Revert "Update poetry.lock"

This reverts commit 676f27e.

* update only jdk4py

* reformat xva

* remove unwanted csv

* adding SBM to the list of notebook with errors

Co-authored-by: Hui Fang Yeo <hfy@activeviam.com>
@bloussou bloussou removed their assignment Jan 4, 2022
@patachoux patachoux bot closed this as completed Jan 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug unexpected or wrong behavior
Projects
None yet
Development

No branches or pull requests

2 participants