Skip to content

Commit ef9643d

Browse files
No public description
PiperOrigin-RevId: 811415014
1 parent 81b2818 commit ef9643d

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

google/colab/sql/bigquery.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def validate(sql: str) -> ValidationResult:
105105
bytes_processed = 0
106106
try:
107107
bytes_processed = int(dry_run_series.get('totalBytesProcessed', 0))
108-
except ValueError:
108+
except (TypeError, ValueError):
109109
pass
110110
compiled_sql = dry_run_series.get('dispatchedSql', '')
111111
referenced_tables = dry_run_series.get('referencedTables', None) or []

google/colab/sql/bigquery_test.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,24 @@ def test_validate_sql_with_unknown_exception(self):
377377

378378
self.assertEqual(expected, result)
379379

380+
def test_validate_sql_with_none_bytes_processed(self):
381+
dry_run_result = pandas.Series(
382+
{'totalBytesProcessed': None, 'dispatchedSql': _QUERY}
383+
)
384+
self.mock_read_gbq_colab.return_value = dry_run_result
385+
expected = bigquery.ValidationSuccess(
386+
bytes_processed=0,
387+
compiled_sql=_QUERY,
388+
tables=[],
389+
schema=[],
390+
)
391+
392+
self.assertEqual(expected, bigquery.validate(_QUERY))
393+
394+
self.mock_read_gbq_colab.assert_called_once_with(
395+
_QUERY, dry_run=True, pyformat_args={}
396+
)
397+
380398

381399
class RunTest(unittest.TestCase):
382400

0 commit comments

Comments
 (0)