3737def status (
3838 ctx : typer .Context ,
3939 cycle_id : str = A_ (..., help = 'data load cycle id' ),
40- bad_records : str = O_ (
41- None ,
42- '--bad_records_file' ,
43- help = 'file to use for storing rows that failed to load' ,
44- metavar = 'protocol://DEFINITION.toml' ,
45- callback = lambda ctx , to : SyncerProtocolType ().convert (to , ctx = ctx )
46- )
40+ # bad_records: str = O_(
41+ # None,
42+ # '--bad_records_file',
43+ # help='file to use for storing rows that failed to load',
44+ # metavar='protocol://DEFINITION.toml',
45+ # callback=lambda ctx, to: SyncerProtocolType().convert(to, ctx=ctx)
46+ # )
4747):
4848 """
4949 Get the status of a data load.
@@ -59,18 +59,21 @@ def status(
5959 f'\n Ignored rows: { data ["ignored_row_count" ]} '
6060 )
6161
62- if data ['ignored_row_count' ] > 0 :
63- now = dt .datetime .now ().strftime ('%Y-%m-%dT%H_%M_%S' )
64- fp = f'BAD_RECORDS_{ now } _{ cycle_id } '
65- console .print (
66- f'[red]\n \n Bad records found...\n \t writing to { bad_records .directory / fp } '
67- )
68- data = ts .tsload .bad_records (cycle_id )
69- bad_records .dump (fp , data = data )
62+ # if int( data['ignored_row_count']) > 0:
63+ # now = dt.datetime.now().strftime('%Y-%m-%dT%H_%M_%S')
64+ # fp = f'BAD_RECORDS_{now}_{cycle_id}'
65+ # console.print(
66+ # f'[red]\n\nBad records found...\n\twriting to {bad_records.directory / fp}'
67+ # )
68+ # data = ts.tsload.bad_records(cycle_id)
69+ # bad_records.dump(fp, data=data)
7070
7171 if data ['status' ]['code' ] == 'LOAD_FAILED' :
7272 console .print (f'\n Failure reason:\n [red]{ data ["status" ]["message" ]} [/]' )
7373
74+ if data .get ('parsing_errors' , False ):
75+ console .print (f'[red]{ data ["parsing_errors" ]} ' )
76+
7477
7578@app .command (cls = CSToolsCommand )
7679@depends (
@@ -96,13 +99,13 @@ def file(
9699 has_header_row : bool = O_ (False , '--has_header_row' , show_default = False , help = 'indicates that the input file contains a header row' ),
97100 escape_character : str = O_ ('"' , '--escape_character' , help = 'specifies the escape character used in the input file' ),
98101 enclosing_character : str = O_ ('"' , '--enclosing_character' , help = 'enclosing character in csv source format' ),
99- bad_records : str = O_ (
100- None ,
101- '--bad_records_file' ,
102- help = 'file to use for storing rows that failed to load' ,
103- metavar = 'protocol://DEFINITION.toml' ,
104- callback = lambda ctx , to : SyncerProtocolType ().convert (to , ctx = ctx )
105- ),
102+ # bad_records: str = O_(
103+ # None,
104+ # '--bad_records_file',
105+ # help='file to use for storing rows that failed to load',
106+ # metavar='protocol://DEFINITION.toml',
107+ # callback=lambda ctx, to: SyncerProtocolType().convert(to, ctx=ctx)
108+ # ),
106109 flexible : bool = O_ (False , '--flexible' , show_default = False , help = 'whether input data file exactly matches target schema' , hidden = True )
107110):
108111 """
@@ -120,9 +123,9 @@ def file(
120123 #
121124
122125 opts = {
123- 'target_database ' : target_database ,
124- 'target_table ' : target_table ,
125- 'target_schema ' : target_schema ,
126+ 'database ' : target_database ,
127+ 'table ' : target_table ,
128+ 'schema_ ' : target_schema ,
126129 'empty_target' : empty_target ,
127130 'max_ignored_rows' : max_ignored_rows ,
128131 'date_format' : date_format ,
@@ -138,10 +141,11 @@ def file(
138141 'enclosing_character' : enclosing_character
139142 }
140143
141- with console .status (f'[bold green]Loading { file } to ThoughtSpot..' ):
142- cycle_id = ts .tsload .upload (ts , fp = file , ** opts , verbose = True )
144+ with console .status (f'[bold green]Loading [yellow]{ file } [/] to ThoughtSpot..' ):
145+ with file .open ('r' , encoding = 'utf-8' , newline = '' ) as fd :
146+ cycle_id = ts .tsload .upload (fd , ** opts )
143147
144- console .log (f'Data load cycle_id: { cycle_id } ' )
148+ console .log (f'Data load cycle_id: [cyan] { cycle_id } ' )
145149
146150 # if bad_records is None:
147151 # return
0 commit comments