Google BigQuery cannot read some ORC data - google-cloud-platform

I'm trying to load ORC data files stored in GCS into BigQuery via bq load/bq mk and facing an error below. The data files copied via hadoop discp command from on-prem cluster's Hive instance version 1.2. Most of the orc-files are loaded successfully, but few are not. There is no problem when I read this data from Hive.
Command I used:
$ bq load --source_format ORC hadoop_migration.pm hive/part-v006-o000-r-00000_a_17
Upload complete.
Waiting on bqjob_r7233761202886bd8_00000175f4b18a74_1 ... (1s) Current status: DONE
BigQuery error in load operation: Error processing job '<project>-af9bd5f6:bqjob_r7233761202886bd8_00000175f4b18a74_1': Error while reading data, error message:
The Apache Orc library failed to parse metadata of stripes with error: failed to open /usr/share/zoneinfo/GMT-00:00 - No such file or directory
Indeed, there is no such file and I believe it shouldn't be.
Google doesn't know about this error message but I've found similar problem here: https://issues.apache.org/jira/browse/ARROW-4966. There is a workaround for on-prem servers of creating sym-link to /usr/share/zoneinfo/GMT-00:00. But I'm in a Cloud.
Additionally, I found that if I extract data from orc file via orc-tools into json format I'm able to load that json file into BigQuery. So I suspect that the problem not in the data itself.
Does anybody came across such problem?

Official Google support position below. In short BigQuery doesn't understand some timezone's description and we suggested to change it in the data. Our workaround for this was to convert ORC data to parquet and then load it into table.
Indeed this error can happen. Also when you try to execute a query from the BigQuery Cloud Console such as:
select timestamp('2020-01-01 00:00:00 GMT-00:00')
you’ll get the same error. It is not just related to the ORC import, it’s how BigQuery understands timestamps. BigQuery supports a wide range of representations as described in [1]. So:
“2020-01-01 00:00:00 GMT-00:00” -- incorrect timestamp string literal
“2020-01-01 00:00:00 abcdef” -- incorrect timestamp string literal
“2020-01-01 00:00:00-00:00” -- correct timestamp string literal
In your case the problem is with the representation of the time zone within the ORC file. I suppose it was generated that way by some external system. If you were able to get the “GMT-00:00” string with preceding space replaced with just “-00:00” that would be the correct name of the time zone. Can you change the configuration of the system which generated the file into having a proper time zone string?
Creating a symlink is only masking the problem and not solving it properly. In case of BigQuery it is not possible.
Best regards,
Google Cloud Support
[1] https://cloud.google.com/bigquery/docs/reference/standard-sql/data-types#time_zones

Related

Where to find detailed logs of BigQuery Data Transfer

I am using BQ Data Transfer to move some zipped JSON data from s3 to BQ.
I am receiving the following error and I'd like to dig deeper into it.
"jsonPayload": {"message": "Job xyz (table ybz) failed with error INVALID_ARGUMENT: Error while reading data, error message: JSON table encountered too many errors, giving up. Rows: 1; errors: 1. Please look into the errors[] collection for more details. File: gs://some-file-name; JobID: PID"},
When trying to connect that URL (replacing the gs:// part with https://storage.googleapis.com/) and I get
<Details>Anonymous caller does not have storage.objects.get access to the Google Cloud Storage object. Permission 'storage.objects.get' denied on resource (or it may not exist).</Details>
That storage can't be found on my GCP Storage buckets.
I suspect there are badly formatted JSON, but without clearly looking at the logs and errors I can't get back to the s3 bucket owner with relevant information.
You can refer to this document to BigQuery Data Transfer Service for Amazon S3.
When you load JSON files into BigQuery, note the following:
JSON data must be newline delimited. Each JSON object must be on a separate line in the file.
If you use gzip compression, BigQuery cannot read the data in parallel. Loading compressed JSON data into BigQuery is slower than loading uncompressed data.
You cannot include both compressed and uncompressed files in the same load job.
The maximum size for a gzip file is 4 GB.
BigQuery supports the JSON type even if schema information is not known at the time of ingestion. A field that is declared as JSON type is loaded with the raw JSON values.
For more information regarding limitations about the Amazon S3 transfers you can refer to this document.
To view logs of BigQuery Data transfers in logs explorer, you can use this filter:
resource.type="bigquery_dts_config"
labels.run_id="transfer_run_id"

Export data from Hive to AWS Redshift

I'm trying to export 1TB of hive data using hive -e as we dont have option to access hdfs file system and load the data to Redshift . The data has been exported in multiple small files like 30000+ small PARQUET files sums upto 1TB of data. To load the data into redshift it is throwing a error
String contains invalid or unsupported UTF8 codepoints. Bad UTF8 hex sequence: e9 (error 2)
Options Tried:
ACCEPTINVCHARS -- which is not available for parquet format
Try to load using Athena -> Glue cralwer -> Redshift . Not straightforward solution as we have to do the same in 40+ tables in hive.
How to build a pipeline to copy the data from Hive and load into Redshift . S3 load also can be skipped.
I've held off on answering since I'm not a Hive expert. The issue is the character encoding of the files. Redshift uses multi-byte UTF8 (like most of the internet) and these files are encoded differently (likely UTF16 coming from Windows, but that is just a guess). I believe that Hive can operate on both of these character sets (by configuring the SerDe but again I'm not a Hive expert). What I don't know is if Hive can read in one encoding and export in another.
When I have used Hive it has preserved the input encoding to the output. So one option would be to change the file encodings to UTF8 from the source system feeding Hive. In the past I've done this from mySQL - export from mySQL in UTF8 and feed through Hive to Redshift. This is the easiest approach as it is just configuring a step that already exists.
Another approach is to convert the files from one encoding to the other. the Linux command iconv does this or you could write some code for a Lambda. This step could be inserted before or after Hive. You will need to know the current file encoding which should be in the file BOM. You can read this with the Linux command 'file '.
As I said above if Hive can do the conversion that would be great. I just don't know if it does this.
Bottom line - The issue is with the file encodings that Hive is running upon. These need to be changed to UTF8 for Redshift. This can be done at the source system, with a conversion tool, or possibly in Hive.
If you want to know a lot more on the subject see: https://github.com/boostcon/cppnow_presentations_2014/blob/master/files/unicode-cpp.pdf

BigQuery transfer service: which file causes error?

I'm trying to load around 1000 files from Google Cloud Storage into BigQuery using the BigQuery transfer service, but it appears I have an error in one of my files:
Job bqts_601e696e-0000-2ef0-812d-f403043921ec (table streams) failed with error INVALID_ARGUMENT: Error while reading data, error message: CSV table references column position 19, but line starting at position:206 contains only 19 columns.; JobID: 931777629779:bqts_601e696e-0000-2ef0-812d-f403043921ec
How can I find which file is causing this error?
I feel like this is in the docs somewhere, but I can't seem to find it.
Thanks!
You can use bq show --format=prettyjson -j job_id_here and will show a verbose error about the failed job. You can see more info about the usage of the command in BigQuery managing jobs docs.
I tried this with a failed job of mine wherein I'm loading csv files from a Google Coud Storage bucket in my project.
Command used:
bq show --format=prettyjson -j bqts_xxxx-xxxx-xxxx-xxxx
Here is a snippet of the output. Output is in JSON format:

Solve Incorrect encoding to upload CSV to Google Cloud Platform AI Dataset

I just started with GCP IA and tried to import a dataset.
Following the official documentation Preparing your training data
The CSV file can have any filename, must be UTF-8 encoded, and must end with a .csv extension.
Following these instructions above and be certified that the file is correct
However, after importing dataset to GCP the document lost their encoding.
What should i do to upload with correct text encoding.
I Already tried to upload iso-8859-1 encoded file but i got following error:
Due to an error, AI Platform was unable to import data into dataset "...".
Additional Details:
Operation State: Failed with errors
Resource Name:
projects/ ...
Error Messages: INTERNAL

AWS Glue - Avro snappy compression read error - HIVE_CANNOT_OPEN_SPLIT: Error opening Hive split

After saving Avro files with snappy compression (also same error with gzip/bzip2 compression) in S3 using AWS Glue, when I try to read the data in athena using AWS Crawler, I get the following error - HIVE_CANNOT_OPEN_SPLIT: Error opening Hive split - using org.apache.hadoop.hive.ql.io.avro.AvroContainerInputFormat: Not a data file. Any idea why I get this error and how to resolve this?
Thank you.
Circumvented this issue by attaching native spark avro jar file to the glue job during execution and using native spark read/write methods to write them in avro format and for the compression setting spark.conf.set("spark.sql.avro.compression.codec","snappy") as soon as the spark session is created.
Works perfectly for me and could be read via Athena as well.
AWS Glue doesn't support writing avro with compression files even though it's not stated clearly in docs. A job succeeds but it applies compressions in a wrong way: instead of compressing file blocks it compresses entire file that is wrong and that's the reason why Athena can't query it.
There are plans to fix the issue but I don't know ETA.
It would be nice if you could contact AWS support to let them know that you are having this issue too (more customers affected - sooner fixed)