Skip to content

Commit 73b2c28

Browse files
committed
BUG: cast DATE BQ columns to STRING
DATE is not supported by pandas
1 parent 0b2ae00 commit 73b2c28

4 files changed

Lines changed: 3 additions & 5 deletions

File tree

scripts/python/idc_index_data_manager.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,6 @@ def execute_sql_query(
250250
query_job_result = self.client.query(sql_query).result()
251251
schema = query_job_result.schema # Get schema from BigQuery QueryJob
252252
index_df = query_job_result.to_dataframe()
253-
if "StudyDate" in index_df.columns:
254-
index_df["StudyDate"] = index_df["StudyDate"].astype(str)
255253
output_basename = Path(file_path).name.split(".")[0]
256254
logger.debug("Executed SQL query from file: %s", file_path)
257255
return index_df, output_basename, schema, sql_query

scripts/sql/analysis_results_index.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ SELECT
2626
Modalities,
2727
# description:
2828
# timestamp of the last update to the analysis results collection
29-
Updated,
29+
SAFE_CAST(Updated AS STRING) AS Updated,
3030
# description:
3131
# license URL for the analysis results collection
3232
license_url,

scripts/sql/collections_index.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ SELECT
3535
Status,
3636
# description:
3737
# timestamp of the last update to the collection
38-
Updated,
38+
SAFE_CAST(Updated AS STRING) AS Updated,
3939
# description:
4040
# detailed information about the collection
4141
Description

scripts/sql/idc_index.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ SELECT
3636
# study level attributes
3737
# description:
3838
# date of the study (de-identified) (DICOM attribute)
39-
ANY_VALUE(StudyDate) AS StudyDate,
39+
ANY_VALUE(SAFE_CAST(StudyDate AS STRING)) AS StudyDate,
4040
# description:
4141
# textual description of the study content (DICOM attribute)
4242
ANY_VALUE(StudyDescription) AS StudyDescription,

0 commit comments

Comments
 (0)