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

[Bug] [Microbatch] _render_event_time_filtered compares timestamp column with string literal #365

Open
2 tasks done
damian3031 opened this issue Nov 29, 2024 · 0 comments
Labels
bug Something isn't working microbatch Issues related to the microbatch incremental strategy

Comments

@damian3031
Copy link

Is this a new bug?

  • I believe this is a new bug
  • I have searched the existing issues, and I could not find an existing issue for this bug

Current Behavior

_render_event_time_filtered compares a timestamp column with a string literal.

Currently, filter condition evaluates to something like:

event_time >= '2020-01-01 00:00:00+00:00'

Since event_time column is expected to be of a datetime type, this will only work on platforms that support implicit type coercion between strings and datetime types.

Expected Behavior

event_time column is compared with a timestamp literal:

event_time >= timestamp '2020-01-01 00:00:00+00:00'

or with a value explicitly cast to a timestamp:

event_time >= cast('2020-01-01 00:00:00+00:00' as timestamp)

Steps To Reproduce

Run incremental model with microbatch strategy and inspect queried sqls.

Relevant log output

No response

Environment

dbt-adapters: v1.10.3

Additional Context

It can be hardcoded in an f-string as below:

filter = f"{event_time_filter.field_name} >= timestamp '{event_time_filter.start}'"

or maybe we could use convert_datetime_type function, which returns a datetime type specific to the adapter.

@damian3031 damian3031 added bug Something isn't working triage labels Nov 29, 2024
@amychen1776 amychen1776 added microbatch Issues related to the microbatch incremental strategy and removed triage labels Dec 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working microbatch Issues related to the microbatch incremental strategy
Projects
None yet
Development

No branches or pull requests

2 participants