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

Teradata invalid strftime function - DATE colums failing #740

Closed
nehanene15 opened this issue Feb 17, 2023 · 6 comments · Fixed by #747
Closed

Teradata invalid strftime function - DATE colums failing #740

nehanene15 opened this issue Feb 17, 2023 · 6 comments · Fixed by #747
Assignees

Comments

@nehanene15
Copy link
Collaborator

The Teradata implementation of strftime compiles FORMAT_DATE() which is an invalid function.

This needs to be changed to a CAST(date_column AS DATE FORMAT 'DD-MM-YYYY')

@nj1973 nj1973 self-assigned this Feb 21, 2023
@nehanene15 nehanene15 changed the title Teradata invalid strftime function Teradata invalid strftime function - DATE colums failing Feb 21, 2023
@nehanene15
Copy link
Collaborator Author

Error message when running a TD to BQ hash validation on a DATE column:

/usr/local/lib/python3.8/dist-packages/third_party/ibis/ibis_teradata/client.py:156: FutureWarning: Using short name for 'orient' is deprecated. Only the options: ('dict', list, 'series', 'split', 'records', 'index') will be used in a future version. Use one of the above to silence this warning.
  schema_list = schema_df.to_dict(orient="record")
Traceback (most recent call last):
  File "/usr/local/bin/data-validation", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.8/dist-packages/data_validation/__main__.py", line 600, in main
    validate(args)
  File "/usr/local/lib/python3.8/dist-packages/data_validation/__main__.py", line 576, in validate
    run(args)
  File "/usr/local/lib/python3.8/dist-packages/data_validation/__main__.py", line 532, in run
    config_managers = build_config_managers_from_args(args)
  File "/usr/local/lib/python3.8/dist-packages/data_validation/__main__.py", line 304, in build_config_managers_from_args
    config_manager = build_config_from_args(args, config_manager)
  File "/usr/local/lib/python3.8/dist-packages/data_validation/__main__.py", line 186, in build_config_from_args
    config_manager.append_calculated_fields(get_calculated_config(args, config_manager))
  File "/usr/local/lib/python3.8/dist-packages/data_validation/__main__.py", line 128, in get_calculated_config
    fields = config_manager.build_dependent_aliases("hash", col_list)
  File "/usr/local/lib/python3.8/dist-packages/data_validation/config_manager.py", line 822, in build_dependent_aliases
    col = self._apply_base_cast_overrides(column, col)
  File "/usr/local/lib/python3.8/dist-packages/data_validation/config_manager.py", line 741, in _apply_base_cast_overrides
    self._strftime_format(
  File "/usr/local/lib/python3.8/dist-packages/data_validation/config_manager.py", line 716, in _strftime_format
    if isinstance(client, clients.OracleClient):
TypeError: isinstance() arg 2 must be a type or tuple of types

@nj1973
Copy link
Contributor

nj1973 commented Feb 21, 2023

The above issue should be fixed by PR: #736

@nj1973
Copy link
Contributor

nj1973 commented Feb 21, 2023

But the problem in this issue still needs to be looked at separately.

@nj1973
Copy link
Contributor

nj1973 commented Feb 21, 2023

@nehanene15 I've made some changes the associated branch for this issue, including adding an integration test.
On the face of it, it appeared to be a simple task of duplicating the strftime code from either Oracle or PostgreSQL and fine tuning the format tokens. The previous code appeared to be a copy of the BigQuery code which is why it didn't work.
However I ran into trouble with the copied code, the column name was being turned into a string and I couldn't for the life of me figure out why.
So I've commited working code but it doesn't feel right so I wondered if you had someone else who could take a look? Perhaps they could backout my commit and correctly copy the strftime code?

@nehanene15
Copy link
Collaborator Author

@nj1973 Interesting... I can test this out now and try copying the code from scratch..

@nehanene15
Copy link
Collaborator Author

@nj1973 I had to make the same changes as you to get the code working.. I think its normal for it to look different compared to Oracle/Postgres since SQLAlchemy doesn't support Teradata so the functions/column name compilations look different

@nj1973 nj1973 linked a pull request Feb 22, 2023 that will close this issue
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

Successfully merging a pull request may close this issue.

2 participants