Class BigQueryHelpers
java.lang.Object
org.apache.beam.sdk.io.gcp.bigquery.BigQueryHelpers
A set of helper functions and classes used by
BigQueryIO.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondataCatalogSegments(com.google.api.services.bigquery.model.TableReference ref, BigQueryOptions options) static <T> @PolyNull TfromJsonString(@PolyNull String json, Class<T> clazz) static @Nullable BigIntegergetNumRows(BigQueryOptions options, com.google.api.services.bigquery.model.TableReference tableRef) It returns the number of rows for a given table.static @Nullable com.google.api.services.bigquery.model.TablegetTable(BigQueryOptions options, com.google.api.services.bigquery.model.TableReference tableRef) static com.google.api.services.bigquery.model.TableReferenceparseTableSpec(String tableSpec) Parse a table specification in the form"[project_id]:[dataset_id].[table_id]"or"[project_id].[dataset_id].[table_id]"or"[dataset_id].[table_id]".static com.google.api.services.bigquery.model.TableReferenceparseTableUrn(String tableUrn) static StringstripPartitionDecorator(String tableSpec) Strip off any partition decorator information from a tablespec.toJsonString(@PolyNull Object item) static StringtoTableSpec(com.google.api.services.bigquery.model.TableReference ref) Returns a canonical string representation of theTableReference.
-
Constructor Details
-
BigQueryHelpers
public BigQueryHelpers()
-
-
Method Details
-
toTableSpec
Returns a canonical string representation of theTableReference. -
dataCatalogSegments
public static List<String> dataCatalogSegments(com.google.api.services.bigquery.model.TableReference ref, BigQueryOptions options) -
parseTableSpec
public static com.google.api.services.bigquery.model.TableReference parseTableSpec(String tableSpec) Parse a table specification in the form"[project_id]:[dataset_id].[table_id]"or"[project_id].[dataset_id].[table_id]"or"[dataset_id].[table_id]".Lakehouse runtime catalog (BigLake metastore) tables are referenced with four parts,
"[project_id].[catalog_id].[namespace_id].[table_id]"(or"[project_id]:[catalog_id].[namespace_id].[table_id]"); these parse to a composite"[catalog_id].[namespace_id]"dataset id, which is the form the BigQuery APIs accept for such tables. More generally, when a specification contains more than three segments, everything between the project id and the final (table) segment becomes the dataset id.If the project id is omitted, the default project id is used.
-
parseTableUrn
-
stripPartitionDecorator
Strip off any partition decorator information from a tablespec. -
toJsonString
-
fromJsonString
-
getNumRows
public static @Nullable BigInteger getNumRows(BigQueryOptions options, com.google.api.services.bigquery.model.TableReference tableRef) throws InterruptedException, IOException It returns the number of rows for a given table.- Returns:
- The number of rows in the table or null if it cannot get any estimate.
- Throws:
InterruptedExceptionIOException
-
getTable
public static @Nullable com.google.api.services.bigquery.model.Table getTable(BigQueryOptions options, com.google.api.services.bigquery.model.TableReference tableRef) throws InterruptedException, IOException - Throws:
InterruptedExceptionIOException
-