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

create_table() should give better error for bad schema argument #140

Open
et-dynamic opened this issue Nov 6, 2024 · 1 comment
Open

Comments

@et-dynamic
Copy link

I stumbled upon this when providing a column name in all caps, but it seems to happen when you provide any bad schema.

good_schema = [{"name": "colname", "type": "varchar"}]
all_caps_colname_schema = [{"name": "COLNAME", "type": "varchar"}]
empty_schema = [{}]

# creates table successfully
dune.create_table(
    namespace = namespace,
    table_name = table_name + "_good",
    schema = good_schema
)

# does not create a table, and does not tell me that the all-caps column name is an issue
dune.create_table(
    namespace = namespace,
    table_name = table_name + "_all_caps",
    schema = all_caps_colname_schema
)

# ditto - same error
dune.create_table(
    namespace = namespace,
    table_name = table_name + "_empty_schema",
    schema = empty_schema
)

Here's the stack trace which is the same for the last 2 cases:

Traceback (most recent call last):
  File "~/path/to/create_table_bug.py", line 21, in <module>
    dune.create_table(
  File "~/dune-pipeline-env/lib/python3.12/site-packages/dune_client/api/table.py", line 83, in create_table
    return CreateTableResult.from_dict(result_json)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "~/dune-pipeline-env/lib/python3.12/site-packages/dataclasses_json/api.py", line 70, in from_dict
    return _decode_dataclass(cls, kvs, infer_missing)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "~/dune-pipeline-env/lib/python3.12/site-packages/dataclasses_json/core.py", line 185, in _decode_dataclass
    field_value = kvs[field.name]
                  ~~~^^^^^^^^^^^^
KeyError: 'example_query'
@bh2smith
Copy link
Collaborator

Ya that's definitely an unusual error. Is this something you'd like to take a stab at fixing?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants