-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
feat(ingest): add output schema inference for sql parser #8989
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not following how some of these methods get called. Just want to make sure there's no performance concerns here, as I know sql parsing can be kinda slow as is
arbitrary_types_allowed=True, | ||
json_encoders={ | ||
SchemaFieldDataTypeClass: lambda v: v.to_obj(), | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm gonna need a mini pydantic tutorial at some point
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm honestly not too happy with this setup, but it's fine for now
# Try to figure out the types of the output columns. | ||
try: | ||
statement = sqlglot.optimizer.annotate_types.annotate_types( | ||
statement, schema=sqlglot_db_schema | ||
) | ||
except sqlglot.errors.OptimizeError as e: | ||
# This is not a fatal error, so we can continue. | ||
logger.debug("sqlglot failed to annotate types: %s", e) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this be slow? I think it'd be nice to only do this if a config option is specified
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this step should be pretty fast
), | ||
# TODO: None of these columns have upstreams? | ||
# That doesn't seem right - we probably need to add fake schemas for the two tables above. | ||
cols = [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice
Merging through flaky smoke tests. |
Checklist