-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
🎉 Google Ads improvement: Support user-specified queries #5302
Conversation
/test connector=connectors/source-google-ads
|
/test connector=connectors/source-google-ads
|
/test connector=connectors/source-google-ads
|
/test connector=connectors/source-google-ads
|
@@ -69,6 +108,11 @@ def streams(self, config: Mapping[str, Any]) -> List[Stream]: | |||
incremental_stream_config = dict( | |||
api=google_api, conversion_window_days=config["conversion_window_days"], start_date=config["start_date"] | |||
) | |||
|
|||
custom_query_streams = [ |
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.
is it possible to validate custom queries in the check_connection
method?
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.
Maybe we can use this for validating queries.
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.
used regex in spec.json, since google query validator works on client (UI javascript) side
|
||
custom_query_streams = [ | ||
CustomQuery(custom_query_config=config["custom_query"][i], **incremental_stream_config) | ||
for i in range(len(config.get("custom_query", []))) |
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.
why do we need range here???
for stream in self.streams(config=config): | ||
if not isinstance(stream, (CustomQueryFullRefresh, CustomQueryIncremental)): | ||
streams.append(stream.as_airbyte_stream()) | ||
# TODO: extend with custom defined streams |
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 sure if you did this here actually, is this still a relevant comment?
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.
just a mark where the default discover logic was extended, will be removed
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.
you don't need to change it at all, just implement this in streams
if not isinstance(stream, (CustomQueryFullRefresh, CustomQueryIncremental)): | ||
streams.append(stream.as_airbyte_stream()) | ||
# TODO: extend with custom defined streams | ||
for usr_query in config.get("custom_query", []): |
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.
why don't you do this inside CustomQueryFullRefresh
and CustomQueryIncremental
classes ?
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.
we need this to be made in discover, to fill schemas (dynamically, it is very important)
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.
what stops you from doing this in streams??? this is what get_json_schema for
d8994c9
to
93de86a
Compare
ae86f71
to
dde02b2
Compare
/test connector=connectors/source-google-ads
|
dde02b2
to
dae0d6f
Compare
/test connector=connectors/source-google-ads
|
dae0d6f
to
612ffc3
Compare
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.
looks great! one question on conflicting where
clauses
@@ -67,6 +67,27 @@ | |||
"maximum": 1095, | |||
"default": 14, | |||
"examples": [14] | |||
}, | |||
"custom_queries": { | |||
"type": "array", |
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.
"type": "array", | |
"type": "array", | |
"title": "Custom GAQL Queries" |
if google_data_type == "ENUM": | ||
field_value = {"type": "string", "enum": list(node.enum_values)} | ||
elif google_data_type == "MESSAGE": # this can be anything (or skip as additionalproperties) ? | ||
output_type = ["string", "number", "array", "object", "boolean", "null"] |
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.
let's just make it a string and cast it as that
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.
Done, but it took some time, also added test for stream that contains MESSAGE field.
result_query = query.replace(columns, new_columns) | ||
|
||
# Modify/insert where condition | ||
where_cond = CustomQuery.WHERE_EXPR.search(result_query) |
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 is a very cool approach, I like it. The only issue I see here is WHERE
could contain a time-bound function like LAST_14_DAYS
etc. then wouldn't it conflict with this incremental logic?
In this case I think we should not add the where condition and just default to what the user did
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.
In this case I've added checking if custom query contain "segments.date" field on check_connection method. It wont allow adding time-bound conditions to custom queries.
/test connector=connectors/source-google-ads
|
/test connector=connectors/source-google-ads
|
/publish connector=connectors/source-google-ads
|
What
Closes #5165
Also this one #5873
How
This allow user to specify the custom GAQL queries as a base for report builder.However, there are some limitations for now:
* if user wants stream to be incremental, he should not use literalsWHERE
andORDER BY
. Currently supported format isSELECT a, b,c,d,e ... FROM table
. The constructions above should be available for full-refresh streams, but it is not recommended.* we do not validate queries for now, as well do not check fields compatibility one with another. Those may be done by user manually usingquery builder
Recommended reading order
x.java
y.python
Pre-merge Checklist
Expand the relevant checklist and delete the others.
New Connector
Community member or Airbyter
airbyte_secret
./gradlew :airbyte-integrations:connectors:<name>:integrationTest
.README.md
docs/SUMMARY.md
docs/integrations/<source or destination>/<name>.md
including changelog. See changelog exampledocs/integrations/README.md
airbyte-integrations/builds.md
Airbyter
If this is a community PR, the Airbyte engineer reviewing this PR is responsible for the below items.
/test connector=connectors/<name>
command is passing./publish
command described hereUpdating a connector
Community member or Airbyter
airbyte_secret
./gradlew :airbyte-integrations:connectors:<name>:integrationTest
.README.md
docs/integrations/<source or destination>/<name>.md
including changelog. See changelog exampleAirbyter
If this is a community PR, the Airbyte engineer reviewing this PR is responsible for the below items.
/test connector=connectors/<name>
command is passing./publish
command described hereConnector Generator
-scaffold
in their name) have been updated with the latest scaffold by running./gradlew :airbyte-integrations:connector-templates:generator:testScaffoldTemplates
then checking in your changes