public class SchemasUtils
extends java.lang.Object
SchemasUtils Class to read JSON based schema. Is there available to read from file or
from string. Currently supported local File System and GCS.| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
DEADLETTER_SCHEMA |
| Constructor and Description |
|---|
SchemasUtils(java.lang.String schema) |
SchemasUtils(java.lang.String path,
java.nio.charset.Charset encoding) |
| Modifier and Type | Method and Description |
|---|---|
org.apache.beam.sdk.schemas.Schema |
getBeamSchema() |
com.google.api.services.bigquery.model.TableSchema |
getBigQuerySchema() |
static java.lang.String |
getGcsFileAsString(java.lang.String filePath)
Reads a file from GCS and returns it as a string.
|
java.lang.String |
getJsonBeamSchema() |
static byte[] |
readGcsFile(java.lang.String gcsFilePath)
Method to read a schema file from GCS and return the file contents as a string.
|
public static final java.lang.String DEADLETTER_SCHEMA
public SchemasUtils(java.lang.String schema)
public SchemasUtils(java.lang.String path,
java.nio.charset.Charset encoding)
throws java.io.IOException
java.io.IOExceptionpublic com.google.api.services.bigquery.model.TableSchema getBigQuerySchema()
public static byte[] readGcsFile(java.lang.String gcsFilePath)
throws java.io.IOException
gcsFilePath - path to file in GCS in format "gs://your-bucket/path/to/file"java.io.IOException - thrown if not able to read filepublic org.apache.beam.sdk.schemas.Schema getBeamSchema()
public java.lang.String getJsonBeamSchema()
public static java.lang.String getGcsFileAsString(java.lang.String filePath)
filePath - path to file in GCSjava.io.IOException - thrown if not able to read file