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

source-redshift-batch: Enable schema inference (while still doing full discovery) #2178

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion source-redshift-batch/.snapshots/TestBasicCapture-Discovery
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ Binding 0:
"id": {
"type": "integer"
}
}
},
"x-infer-schema": true
},
"key": [
"/id"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
# ================================
# Final State Checkpoint
# ================================
{"bindingStateV1":{"test_basic_datatypes_13111208":{"LastPolled":"<TIMESTAMP>"}}}
{"bindingStateV1":{"test_basic_datatypes_13111208":{"CursorNames":null,"CursorValues":null,"LastPolled":"<TIMESTAMP>"}}}

Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,10 @@ Binding 0:
]
},
"a_real": {
"format": "number",
"type": [
"number",
"string",
"null"
]
},
Expand All @@ -74,7 +76,8 @@ Binding 0:
"id": {
"type": "integer"
}
}
},
"x-infer-schema": true
},
"key": [
"/id"
Expand Down
8 changes: 4 additions & 4 deletions source-redshift-batch/.snapshots/TestFloatNaNs-Capture
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# ================================
# Collection "acmeCo/test/test_float_nans_10511": 3 Documents
# ================================
{"_meta":{"polled":"<TIMESTAMP>","index":999},"a_double":"NaN","a_real":2,"id":0,"txid":999999}
{"_meta":{"polled":"<TIMESTAMP>","index":999},"a_double":3,"a_real":"NaN","id":1,"txid":999999}
{"_meta":{"polled":"<TIMESTAMP>","index":999},"a_double":"-Infinity","a_real":"Infinity","id":2,"txid":999999}
{"_meta":{"polled":"<TIMESTAMP>","index":999},"a_double":"NaN","a_real":2,"id":0}
{"_meta":{"polled":"<TIMESTAMP>","index":999},"a_double":3,"a_real":"NaN","id":1}
{"_meta":{"polled":"<TIMESTAMP>","index":999},"a_double":"-Infinity","a_real":"Infinity","id":2}
# ================================
# Final State Checkpoint
# ================================
{"bindingStateV1":{"test_float_nans_10511":{"CursorNames":["txid"],"CursorValues":[999999],"LastPolled":"<TIMESTAMP>"}}}
{"bindingStateV1":{"test_float_nans_10511":{"CursorNames":null,"CursorValues":null,"LastPolled":"<TIMESTAMP>"}}}

70 changes: 70 additions & 0 deletions source-redshift-batch/.snapshots/TestFloatNaNs-Discovery
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
Binding 0:
{
"resource_config_json": {
"name": "test_float_nans_10511",
"template": "{{if .CursorFields -}}\n {{- if .IsFirstQuery -}}\n SELECT * FROM \"test\".\"float_nans_10511\"\n {{- else -}}\n SELECT * FROM \"test\".\"float_nans_10511\"\n\t{{- range $i, $k := $.CursorFields -}}\n\t {{- if eq $i 0}} WHERE ({{else}}) OR ({{end -}}\n {{- range $j, $n := $.CursorFields -}}\n\t\t{{- if lt $j $i -}}\n\t\t {{$n}} = ${{add $j 1}} AND {{end -}}\n\t {{- end -}}\n\t {{$k}} \u003e ${{add $i 1}}\n\t{{- end -}}\n\t) \n {{- end}} ORDER BY {{range $i, $k := $.CursorFields}}{{if gt $i 0}}, {{end}}{{$k}}{{end -}};\n{{- else -}}\n SELECT * FROM \"test\".\"float_nans_10511\";\n{{- end}}\n"
},
"resource_path": [
"test_float_nans_10511"
],
"collection": {
"name": "acmeCo/test/test_float_nans_10511",
"read_schema_json": {
"type": "object",
"required": [
"_meta",
"id"
],
"properties": {
"_meta": {
"$schema": "http://json-schema.org/draft/2020-12/schema",
"$id": "https://github.com/estuary/connectors/source-redshift-batch/document-metadata",
"properties": {
"polled": {
"type": "string",
"format": "date-time",
"title": "Polled Timestamp",
"description": "The time at which the update query which produced this document as executed."
},
"index": {
"type": "integer",
"title": "Result Index",
"description": "The index of this document within the query execution which produced it."
}
},
"type": "object",
"required": [
"polled",
"index"
]
},
"a_double": {
"format": "number",
"type": [
"number",
"string",
"null"
]
},
"a_real": {
"format": "number",
"type": [
"number",
"string",
"null"
]
},
"id": {
"type": "integer"
}
},
"x-infer-schema": true
},
"key": [
"/id"
],
"projections": null
},
"state_key": "test_float_nans_10511"
}

3 changes: 2 additions & 1 deletion source-redshift-batch/.snapshots/TestKeyDiscovery
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ Binding 0:
"k_str": {
"type": "string"
}
}
},
"x-infer-schema": true
},
"key": [
"/k_smallint",
Expand Down
3 changes: 2 additions & 1 deletion source-redshift-batch/.snapshots/TestKeylessDiscovery
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ Binding 0:
"null"
]
}
}
},
"x-infer-schema": true
},
"projections": null
},
Expand Down
3 changes: 2 additions & 1 deletion source-redshift-batch/.snapshots/TestSchemaFilter-FilteredIn
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ Binding 0:
"id": {
"type": "integer"
}
}
},
"x-infer-schema": true
},
"key": [
"/id"
Expand Down
3 changes: 2 additions & 1 deletion source-redshift-batch/.snapshots/TestSchemaFilter-Unfiltered
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ Binding 0:
"id": {
"type": "integer"
}
}
},
"x-infer-schema": true
},
"key": [
"/id"
Expand Down
3 changes: 2 additions & 1 deletion source-redshift-batch/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ func generateCollectionSchema(keyColumns []string, columnTypes map[string]column
Required: required,
AdditionalProperties: nil,
Extras: map[string]interface{}{
"properties": properties,
"properties": properties,
"x-infer-schema": true,
},
}

Expand Down
Loading