Skip to content

Commit a25f691

Browse files
authored
add enable_schema_warning setting (#250)
add a setting to enable or disable the `"No schema for record field"` warning
1 parent 1816a16 commit a25f691

File tree

2 files changed

+13
-19
lines changed

2 files changed

+13
-19
lines changed

target_redshift/sinks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ def parse_timestamps_in_record(
325325
"""
326326
for key, value in record.items():
327327
if key not in schema["properties"]:
328-
if value is not None:
328+
if value is not None and self.config["enable_schema_warning"]:
329329
self.logger.warning("No schema for record field '%s'", key)
330330
continue
331331
datelike_type = get_datelike_property_type(schema["properties"][key])

target_redshift/target.py

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -57,17 +57,13 @@ def __init__(
5757
th.Property(
5858
"host",
5959
th.StringType,
60-
description=(
61-
"Hostname for redshift instance."
62-
),
60+
description=("Hostname for redshift instance."),
6361
),
6462
th.Property(
6563
"port",
6664
th.StringType,
6765
default="5439",
68-
description=(
69-
"The port on which redshift is awaiting connection."
70-
),
66+
description=("The port on which redshift is awaiting connection."),
7167
),
7268
th.Property(
7369
"enable_iam_authentication",
@@ -89,25 +85,17 @@ def __init__(
8985
th.Property(
9086
"user",
9187
th.StringType,
92-
description=(
93-
"User name used to authenticate. Note if sqlalchemy_url is set this "
94-
"will be ignored."
95-
),
88+
description=("User name used to authenticate. Note if sqlalchemy_url is set this " "will be ignored."),
9689
),
9790
th.Property(
9891
"password",
9992
th.StringType,
100-
description=(
101-
"Password used to authenticate. Note if sqlalchemy_url is set this "
102-
"will be ignored."
103-
),
93+
description=("Password used to authenticate. Note if sqlalchemy_url is set this " "will be ignored."),
10494
),
10595
th.Property(
10696
"dbname",
10797
th.StringType,
108-
description=(
109-
"Database name. Note if sqlalchemy_url is set this will be ignored."
110-
),
98+
description=("Database name. Note if sqlalchemy_url is set this will be ignored."),
11199
title="Database Name",
112100
),
113101
th.Property(
@@ -212,7 +200,13 @@ def __init__(
212200
"grants",
213201
th.ArrayType(th.StringType),
214202
description="List of users/roles/groups that will have select permissions on the tables",
215-
)
203+
),
204+
th.Property(
205+
"enable_schema_warning",
206+
th.BooleanType,
207+
default=True,
208+
description=("If true, the target will log a warning when a record is not found in the schema."),
209+
),
216210
).to_dict()
217211

218212
default_sink_class = RedshiftSink

0 commit comments

Comments
 (0)