Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setPreserveAsciiControlChars flag not working, #2976

Open
sudhanshubanerjee opened this issue Oct 30, 2023 · 0 comments · May be fixed by #2977
Open

setPreserveAsciiControlChars flag not working, #2976

sudhanshubanerjee opened this issue Oct 30, 2023 · 0 comments · May be fixed by #2977
Assignees
Labels
api: bigquery Issues related to the googleapis/java-bigquery API.

Comments

@sudhanshubanerjee
Copy link

Hi Team,

I tried to use CSVOption#setPreserveAsciiControlChars, when using the latest 2.34.0 version.

I have made the fixes for my use case, but request you to add fix in main code.

diff --git a/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/LoadJobConfiguration.java b/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/LoadJobConfiguration.java
index fefff340..1696b1fc 100644
--- a/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/LoadJobConfiguration.java
+++ b/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/LoadJobConfiguration.java
@@ -152,7 +152,8 @@ public final class LoadJobConfiguration extends JobConfiguration implements Load
|| loadConfigurationPb.getEncoding() != null
|| loadConfigurationPb.getFieldDelimiter() != null
|| loadConfigurationPb.getQuote() != null

  •      || loadConfigurationPb.getSkipLeadingRows() != null) {
    
  •      || loadConfigurationPb.getSkipLeadingRows() != null
    
  •      || loadConfigurationPb.getPreserveAsciiControlCharacters() != null) {
       CsvOptions.Builder builder =
           CsvOptions.newBuilder()
               .setEncoding(loadConfigurationPb.getEncoding())
    

@@ -167,6 +168,9 @@ public final class LoadJobConfiguration extends JobConfiguration implements Load
if (loadConfigurationPb.getSkipLeadingRows() != null) {
builder.setSkipLeadingRows(loadConfigurationPb.getSkipLeadingRows());
}

  •    if (loadConfigurationPb.getPreserveAsciiControlCharacters() != null) {
    
  •      builder.setPreserveAsciiControlCharacters(loadConfigurationPb.getPreserveAsciiControlCharacters());
    
  •    }
       this.formatOptions = builder.build();
     }
     this.maxBadRecords = loadConfigurationPb.getMaxBadRecords();
    

@@ -653,7 +657,8 @@ public final class LoadJobConfiguration extends JobConfiguration implements Load
.setAllowJaggedRows(csvOptions.allowJaggedRows())
.setAllowQuotedNewlines(csvOptions.allowQuotedNewLines())
.setEncoding(csvOptions.getEncoding())

  •      .setQuote(csvOptions.getQuote());
    
  •      .setQuote(csvOptions.getQuote())
    
  •      .setPreserveAsciiControlCharacters(csvOptions.getPreserveAsciiControlCharacters());
     if (csvOptions.getSkipLeadingRows() != null) {
       // todo(mziccard) remove checked cast or comment when #1044 is closed
       loadConfigurationPb.setSkipLeadingRows(Ints.checkedCast(csvOptions.getSkipLeadingRows()));
    

diff --git a/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/WriteChannelConfiguration.java b/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/WriteChannelConfiguration.java
index 114c6dad..f270eadf 100644
--- a/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/WriteChannelConfiguration.java
+++ b/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/WriteChannelConfiguration.java
@@ -127,7 +127,8 @@ public final class WriteChannelConfiguration implements LoadConfiguration, Seria
|| loadConfigurationPb.getEncoding() != null
|| loadConfigurationPb.getFieldDelimiter() != null
|| loadConfigurationPb.getQuote() != null

  •      || loadConfigurationPb.getSkipLeadingRows() != null) {
    
  •      || loadConfigurationPb.getSkipLeadingRows() != null
    
  •      || loadConfigurationPb.getPreserveAsciiControlCharacters() != null) {
       CsvOptions.Builder builder =
           CsvOptions.newBuilder()
               .setEncoding(loadConfigurationPb.getEncoding())
    

@@ -142,6 +143,9 @@ public final class WriteChannelConfiguration implements LoadConfiguration, Seria
if (loadConfigurationPb.getSkipLeadingRows() != null) {
builder.setSkipLeadingRows(loadConfigurationPb.getSkipLeadingRows());
}

  •    if (loadConfigurationPb.getPreserveAsciiControlCharacters() != null) {
    
  •      builder.setPreserveAsciiControlCharacters(loadConfigurationPb.getPreserveAsciiControlCharacters());
    
  •    }
       this.formatOptions = builder.build();
     }
     this.maxBadRecords = loadConfigurationPb.getMaxBadRecords();
    

~

@product-auto-label product-auto-label bot added the api: bigquery Issues related to the googleapis/java-bigquery API. label Oct 30, 2023
@Neenu1995 Neenu1995 self-assigned this Nov 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: bigquery Issues related to the googleapis/java-bigquery API.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants