Home > Blockchain >  Create BigQuery table schema corresponding to table in Oracle DB
Create BigQuery table schema corresponding to table in Oracle DB

Time:07-07

We are trying to copy an Oracle DB (v19c) to BigQuery and wondering what is the best way to create BigQuery table schema. We can't hardcode the schema because the code will need to copy arbitrary table so we don't know at compile time what the schema of the source table is going to be. We are using jOOQ, does it have a helper method that given a table, returns Schema for BQ?

com.google.cloud.bigquery.Schema getBQSchema(String oracleTableName)

If not, how to best go about it?

CodePudding user response:

In jOOQ, the type you're looking for is org.jooq.Meta. It allows you to query your database meta data, based on JDBC's DatabaseMetaData, by default (which you can also use directly, of course).

Any org.jooq.Table that comes out of this org.jooq.Meta type should have a reference to the org.jooq.Schema that it's defined in. It's not of the type com.google.cloud.bigquery.Schema, but you can probably populate your own lookups based on the above?

  • Related