Skip to content

Commit

Permalink
Update option name and fix line lengths
Browse files Browse the repository at this point in the history
  • Loading branch information
kdeggelman committed Nov 11, 2021
1 parent c64d8ee commit cb73385
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions bigquery_schema_generator/generate_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def __init__(
debugging_map=False,
sanitize_names=False,
ignore_invalid_lines=False,
keep_input_sort_order=False,
preserve_input_sort_order=False,
):
self.input_format = input_format
self.infer_mode = infer_mode
Expand Down Expand Up @@ -114,7 +114,10 @@ def __init__(
# If CSV, preserve the original ordering because 'bq load` matches the
# CSV column with the respective schema entry using the position of the
# column in the schema.
self.sorted_schema = (input_format in {'json', 'dict'}) and not keep_input_sort_order
self.sorted_schema = (
(input_format in {'json', 'dict'})
and not preserve_input_sort_order
)

self.line_number = 0
self.error_logs = []
Expand Down Expand Up @@ -1044,9 +1047,10 @@ def main():
' `bq show --schema <project_id>:<dataset>:<table_name>',
default=None)
parser.add_argument(
'--keep-input-sort-order',
help='Preserve the original ordering of columns from input instead of sorting alphabetically.'
' This only only impacts `input_format` of json or dict',
'--preserve_input_sort_order',
help='Preserve the original ordering of columns from input instead of'
' sorting alphabetically.'
' This only impacts `input_format` of json or dict',
action='store_true'
)
args = parser.parse_args()
Expand All @@ -1063,7 +1067,7 @@ def main():
debugging_map=args.debugging_map,
sanitize_names=args.sanitize_names,
ignore_invalid_lines=args.ignore_invalid_lines,
keep_input_sort_order=args.keep_input_sort_order
preserve_input_sort_order=args.preserve_input_sort_order
)
existing_schema_map = read_existing_schema_from_file(
args.existing_schema_path)
Expand Down

0 comments on commit cb73385

Please sign in to comment.