Skip to content

Instantly share code, notes, and snippets.

@FurcyPin
Created February 13, 2022 15:27
Show Gist options
  • Save FurcyPin/3e4e467d5f79cdf034aa6ee3ccb4a122 to your computer and use it in GitHub Desktop.
Save FurcyPin/3e4e467d5f79cdf034aa6ee3ccb4a122 to your computer and use it in GitHub Desktop.
bq = BigQueryBuilder(get_bq_client())
df = bq.sql('''SELECT 1 as id, STRUCT(1 as a, STRUCT(1 as c, 1 as d) as b) as s''')
df.printSchema()
# root
# |-- id: INTEGER (NULLABLE)
# |-- s: RECORD (NULLABLE)
# | |-- a: INTEGER (NULLABLE)
# | |-- b: RECORD (NULLABLE)
# | | |-- c: INTEGER (NULLABLE)
# | | |-- d: INTEGER (NULLABLE)
flatten(df).printSchema()
# root
# |-- id: INTEGER (NULLABLE)
# |-- s_a: INTEGER (NULLABLE)
# |-- s_b_c: INTEGER (NULLABLE)
# |-- s_b_d: INTEGER (NULLABLE)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment