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

ValueError: DataFusion error: Internal error: Failed to parse -07:00 as a timezone. #549

Open
yubrshen opened this issue Nov 22, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@yubrshen
Copy link

This happened when displaying chart object of Altair VS Code (interactive session, like Jupyter Notebook):
The following column of 'TRIP_TIME' was used in a chart for y value.

Timezone -07:00 caused ValueError
Here are some sample data:

TRIP_TIME	Circuit_Breaker	LOCATION

0 2024-06-02 00:28:47.658000-07:00 WSFD07 Y10
2 2024-06-02 00:30:58.287000-07:00 WSFD08 Y10
4 2024-06-02 00:35:01.977000-07:00 WSFD09 Y10
6 2024-06-02 00:47:47.731000-07:00 WSFD07 Y10
7 2024-06-02 00:47:47.731000-07:00 WSFD08 Y10

ValueError Traceback (most recent call last)
File ~/miniconda3/envs/text-embedding-py312/lib/python3.12/site-packages/IPython/core/formatters.py:977, in MimeBundleFormatter.call(self, obj, include, exclude)
974 method = get_real_method(obj, self.print_method)
976 if method is not None:
--> 977 return method(include=include, exclude=exclude)
978 return None
979 else:

File ~/miniconda3/envs/text-embedding-py312/lib/python3.12/site-packages/altair/vegalite/v5/api.py:2576, in TopLevelMixin.repr_mimebundle(self, include, exclude)
2574 return {}
2575 else:
-> 2576 return renderers.get()(dct)

File ~/miniconda3/envs/text-embedding-py312/lib/python3.12/site-packages/altair/utils/display.py:227, in HTMLRenderer.call(self, spec, **metadata)
224 kwargs.update(metadata)
225 # To get proper return value type, would need to write complex
226 # overload signatures for spec_to_mimebundle based on format
--> 227 return spec_to_mimebundle( # type: ignore[return-value]
228 spec, format="html", output_div=self.output_div, **kwargs
229 )

File ~/miniconda3/envs/text-embedding-py312/lib/python3.12/site-packages/altair/utils/mimebundle.py:70, in spec_to_mimebundle(spec, format, mode, vega_version, vegaembed_version, vegalite_version, embed_options, engine, **kwargs)
68 internal_mode: Literal["vega-lite", "vega"] = mode
69 if using_vegafusion():
---> 70 spec = compile_with_vegafusion(spec)
71 internal_mode = "vega"
73 # Default to the embed options set by alt.renderers.set_embed_options

File ~/miniconda3/envs/text-embedding-py312/lib/python3.12/site-packages/altair/utils/_vegafusion_data.py:226, in compile_with_vegafusion(vegalite_spec)
224 # Pre-evaluate transforms in vega spec with vegafusion
225 row_limit = data_transformers.options.get("max_rows", None)
--> 226 transformed_vega_spec, warnings = vf.runtime.pre_transform_spec(
227 vega_spec,
228 vf.get_local_tz(),
229 inline_datasets=inline_tables,
230 row_limit=row_limit,
231 )
233 # Check from row limit warning and convert to MaxRowsError
234 handle_row_limit_exceeded(row_limit, warnings)

File ~/miniconda3/envs/text-embedding-py312/lib/python3.12/site-packages/vegafusion/runtime.py:371, in VegaFusionRuntime.pre_transform_spec(self, spec, local_tz, default_input_tz, row_limit, preserve_interactivity, inline_datasets, keep_signals, keep_datasets, data_encoding_threshold, data_encoding_format)
369 try:
370 if data_encoding_threshold is None:
--> 371 new_spec, warnings = self.embedded_runtime.pre_transform_spec(
372 spec,
373 local_tz=local_tz,
374 default_input_tz=default_input_tz,
375 row_limit=row_limit,
376 preserve_interactivity=preserve_interactivity,
377 inline_datasets=imported_inline_dataset,
378 keep_signals=keep_signals,
379 keep_datasets=keep_datasets,
380 )
381 else:
382 # Use pre_transform_extract to extract large datasets
383 new_spec, datasets, warnings = self.embedded_runtime.pre_transform_extract(
384 spec,
385 local_tz=local_tz,
(...)
392 keep_datasets=keep_datasets,
393 )

ValueError: DataFusion error: Internal error: Failed to parse -07:00 as a timezone.
This was likely caused by a bug in DataFusion's code and we would welcome that you file an bug report in our issue tracker
Context[0]: Failed to get node value

@jonmmease
Copy link
Collaborator

Thanks for the report!

@jonmmease
Copy link
Collaborator

Hi @yubrshen, VegaFusion's automatic date/time parsing logic isn't as generous as the browser's Date parsing logic. In VegaFusion version 2.0.1, you can specify a custom date parse format like this.

import altair as alt
source = alt.UrlData(
    data.disasters.url,
    format=alt.DataFormat(parse={"TRIP_TIME": "date:%Y-%m-%d %H:%M:%S.%f%Z"})
)
alt.Chart(source)...

Can you give that a try, with version 2.0.1, and see if it works for you?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants