innobi / pantab

Read/Write pandas DataFrames with Tableau Hyper Extracts
BSD 3-Clause "New" or "Revised" License
114 stars 44 forks source link

An error occurred while communicating with the Tableau Data Extract data source 'Untitled Data Source' #334

Closed skyth540 closed 1 month ago

skyth540 commented 1 month ago

Describe the bug I successfully created a .hyper, but in tableau, it is unable to connect to it. Version 2023.1.0

""" Unable to connect to the server. Check that the server is running and that you have access privileges to the requested database. Error Code: FAB9A2C5

[SQLSTATE:0AS01] error opening database 'test': There was an error during loading database: unsupported version. To open this database, please update your product: DatabaseId: "hyper.file:G:/Duda/Data Projects/Kroger 8451/Raw Data New/parquet/test.hyper" Unable to connect to the Tableau Data Extract server "". Check that the server is running and that you have access privileges to the requested database. """

To Reproduce Steps to reproduce the behavior:

import pyarrow.parquet as pq
import pantab as pt

folder_path = r"G:\...\parquets"

table = pq.read_table(folder_path)

path = r"G:\...\test.hyper"

pt.frame_to_hyper(table, path, table = 'test')
RSchaper10 commented 1 month ago

I was able to replicate the issue on my machine as well (Apple M1 Pro Sonoma 14.6.1)

Unable to complete action Unable to connect to the server. Check that the server is running and that you have access privileges to the requested database. Error Code: FAB9A2C5 [SQLSTATE:0AS01] error opening database 'example': There was an error during loading database: unsupported version. To open this database, please update your product: DatabaseId: "hyper.file:/Users/robschaper-m1/Code/pantab/example.hyper" Unable to connect to the Tableau Data Extract server "". Check that the server is running and that you have access privileges to the requested database.

When Attempting to open the example hyper file in Tableau Desktop (2024.2.2), generated using the following in Jupyter Notebook:

import pandas as pd import pantab as pt

df = pd.DataFrame([ ["dog", 4], ["cat", 4], ], columns=["animal", "num_of_legs"])

pt.frame_to_hyper(df, "example.hyper", table="animals")

skyth540 commented 1 month ago

A similar thing happened when opening in alteryx 2021.2

""" error opening database 'test': There was an error during loading database "hyper.file:G:...\test.hyper":unsupported version 4 (max supported version: 1). To open this database, please update your product. Context: 0xd6232f85

"""

WillAyd commented 1 month ago

I think this is a duplicate of https://github.com/innobi/pantab/issues/331

WillAyd commented 1 month ago

If you install from main you should now be able to try:

params = {"default_database_version": "1"}
pt.frame_to_hyper(table, path, table = 'test', process_params=params)

can you see if that works to resolve the issue?

FWIW I asked about the database versions on the Tableau slack today, so hope to hear back about that soon

WillAyd commented 1 month ago

OK Tableau shared the following with me which I think has good info:

https://tableau.github.io/hyper-db/docs/hyper-api/hyper_process/#default_database_version

Looks like version 0 is the default but is deprecated alongside version 1. So I think we should set the default value to 2 and leave it to the user to use a more recent version? @skyth540 that wouldn't solve the issue you are seeing with alteryx by default, but as mentioned in the previous post you can now provide the process_params argument to override that default.

Thoughts?

WillAyd commented 1 month ago

@jorwoods may have some input as well

jorwoods commented 1 month ago

Given the versions of Tableau Desktop/Server/Prep supported, I think setting the hyper version to 2 as a default makes sense. I'll make a PR soon to update the pantab docs to reference that page so pantab users know the implications of updating that setting.

skyth540 commented 1 month ago

I uninstalled pantab, and successfully reinstalled it using pip install git+https://github.com/innobi/pantab.git

I got this error:

----> 4 pt.frame_to_hyper(table, path, table = 'test', process_params=params)

TypeError: frame_to_hyper() got an unexpected keyword argument 'process_params'

So then I cloned the repo, and I can see in _writer.py on my computer where the change is:

`def frame_to_hyper(
    df,
    database: Union[str, pathlib.Path],
    *,
    table: pantab_types.TableNameType,
    table_mode: Literal["a", "w"] = "w",
    not_null_columns: Optional[set[str]] = None,
    json_columns: Optional[set[str]] = None,
    geo_columns: Optional[set[str]] = None,
    process_params: Optional[dict[str, str]] = None,
) -> None:
    """See api.rst for documentation"""
    frames_to_hyper(
        {table: df},
        database,
        table_mode=table_mode,
        not_null_columns=not_null_columns,
        json_columns=json_columns,
        geo_columns=geo_columns,
        process_params=process_params,
    )

and I installed from the clone, but still nothing.

WillAyd commented 1 month ago

@skyth540 hard to say. Might be helpful to post the full traceback and make sure the file paths are resolving to the locations you think they are