Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,8 @@ public BigQueryJdbcRuntimeException(Throwable ex) {
public BigQueryJdbcRuntimeException(String message, InterruptedException ex) {
super(message, ex);
}

public BigQueryJdbcRuntimeException(String message, Throwable ex) {
super(message, ex);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,8 @@ public class BigQueryJdbcSqlSyntaxErrorException extends SQLSyntaxErrorException
public BigQueryJdbcSqlSyntaxErrorException(BigQueryException ex) {
super(ex.getMessage(), "Incorrect SQL syntax.");
}

public BigQueryJdbcSqlSyntaxErrorException(String message, BigQueryException ex) {
super(message, ex);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,10 @@ private BigQueryArrowResultSet(
try {
this.arrowDeserializer = new ArrowDeserializer(arrowSchema);
} catch (IOException ex) {
throw new BigQueryJdbcException(ex);
BigQueryJdbcException e =
new BigQueryJdbcException("IOException during ArrowDeserializer creation", ex);
LOG.severe(e, e.getMessage());
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When we get Mdc working, can this LOG be a part of the exception? At least for exceptions that we own they could log sever errors, so we'll never forget to log it.

throw e;
}
}
}
Expand Down Expand Up @@ -215,8 +218,11 @@ public boolean next() throws SQLException {
checkClosed();
if (this.isNested) {
if (this.currentNestedBatch == null || this.currentNestedBatch.getNestedRecords() == null) {
throw new IllegalStateException(
"currentNestedBatch/JsonStringArrayList can not be null working with the nested record");
IllegalStateException ex =
new IllegalStateException(
"currentNestedBatch/JsonStringArrayList can not be null working with the nested record");
LOG.severe(ex, ex.getMessage());
throw ex;
}
if (this.nestedRowIndex < (this.toIndexExclusive - 1)) {
/* Check if there's a next record in the array which can be read */
Expand All @@ -238,7 +244,10 @@ public boolean next() throws SQLException {
// Advance the cursor. Potentially blocking operation.
BigQueryArrowBatchWrapper batchWrapper = this.buffer.take();
if (batchWrapper.getException() != null) {
throw new BigQueryJdbcRuntimeException(batchWrapper.getException());
BigQueryJdbcRuntimeException ex =
new BigQueryJdbcRuntimeException(batchWrapper.getException());
LOG.severe(ex, ex.getMessage());
throw ex;
}
if (batchWrapper.isLast()) {
/* Marks the end of the records */
Expand Down Expand Up @@ -267,9 +276,12 @@ else if (this.currentBatchRowIndex < this.vectorSchemaRoot.getRowCount()) {
return true;
}
} catch (InterruptedException | SQLException ex) {
throw new BigQueryJdbcException(
"Error occurred while advancing the cursor. This could happen when connection is closed while the next method is being called.",
ex);
BigQueryJdbcException e =
new BigQueryJdbcException(
"Error occurred while advancing the cursor. This could happen when connection is closed while the next method is being called.",
ex);
LOG.severe(e, e.getMessage());
throw e;
}
}
return false;
Expand All @@ -283,12 +295,16 @@ private Object getObjectInternal(int columnIndex) throws SQLException {
// BigQuery doesn't support multidimensional arrays, so
// just the default row num column (1) and the actual column (2) is supposed to be read
if (!(columnIndex == 1 || columnIndex == 2)) {

throw new IllegalArgumentException(
"Column index is required to be 1 or 2 for nested arrays");
IllegalArgumentException ex =
new IllegalArgumentException("Column index is required to be 1 or 2 for nested arrays");
LOG.severe(ex, ex.getMessage());
throw ex;
}
if (this.currentNestedBatch.getNestedRecords() == null) {
throw new IllegalStateException("JsonStringArrayList cannot be null for nested records.");
IllegalStateException ex =
new IllegalStateException("JsonStringArrayList cannot be null for nested records.");
LOG.severe(ex, ex.getMessage());
throw ex;
}
// For Arrays the first column is Index, ref:
// https://docs.oracle.com/javase/7/docs/api/java/sql/Array.html#getResultSet()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,9 @@ protected int getColumnIndex(String columnLabel) throws SQLException {
LOG.finest("++enter++");
checkClosed();
if (columnLabel == null) {
throw new SQLException("Column label cannot be null");
SQLException ex = new SQLException("Column label cannot be null");
LOG.severe(ex, ex.getMessage());
throw ex;
}
// use schema to get the column index, add 1 for SQL index
return this.schemaFieldList.getIndex(columnLabel) + 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -940,7 +940,9 @@ public void registerOutParameter(int paramIndex, int sqlType) throws SQLExceptio
BigQueryParameterHandler.BigQueryStatementParameterType.OUT,
-1);
} catch (Exception e) {
throw new SQLException(e);
SQLException ex = new SQLException(e);
LOG.severe(ex, "Failed to registerOutParameter");
throw ex;
}
}

Expand All @@ -957,7 +959,9 @@ public void registerOutParameter(String paramName, int sqlType) throws SQLExcept
BigQueryParameterHandler.BigQueryStatementParameterType.OUT,
-1);
} catch (Exception e) {
throw new SQLException(e);
SQLException ex = new SQLException(e);
LOG.severe(ex, "Failed to registerOutParameter");
throw ex;
}
}

Expand All @@ -979,7 +983,9 @@ public void registerOutParameter(int paramIndex, int sqlType, int scale) throws
BigQueryParameterHandler.BigQueryStatementParameterType.OUT,
scale);
} catch (Exception e) {
throw new SQLException(e);
SQLException ex = new SQLException(e);
LOG.severe(ex, "Failed to registerOutParameter");
throw ex;
}
}

Expand Down Expand Up @@ -1012,7 +1018,9 @@ public void registerOutParameter(String paramName, int sqlType, int scale) throw
BigQueryParameterHandler.BigQueryStatementParameterType.OUT,
scale);
} catch (Exception e) {
throw new SQLException(e);
SQLException ex = new SQLException(e);
LOG.severe(ex, "Failed to registerOutParameter");
throw ex;
}
}

Expand Down Expand Up @@ -1236,12 +1244,18 @@ public void setObject(String arg0, Object arg1, int arg2) throws SQLException {
if (BigQueryJdbcTypeMappings.standardSQLToJavaSqlTypesMapping.containsKey(sqlType)) {
int javaSqlType = BigQueryJdbcTypeMappings.standardSQLToJavaSqlTypesMapping.get(sqlType);
if (javaSqlType != arg2) {
throw new BigQueryJdbcSqlFeatureNotSupportedException(
String.format("Unsupported sql type:%s ", arg2));
BigQueryJdbcSqlFeatureNotSupportedException ex =
new BigQueryJdbcSqlFeatureNotSupportedException(
String.format("Unsupported sql type:%s ", arg2));
LOG.severe(ex, ex.getMessage());
throw ex;
}
} else {
throw new BigQueryJdbcSqlFeatureNotSupportedException(
String.format("parameter sql type not supported: %s", sqlType));
BigQueryJdbcSqlFeatureNotSupportedException ex =
new BigQueryJdbcSqlFeatureNotSupportedException(
String.format("parameter sql type not supported: %s", sqlType));
LOG.severe(ex, ex.getMessage());
throw ex;
}
}

Expand All @@ -1253,12 +1267,18 @@ public void setObject(String arg0, Object arg1, int arg2, int arg3) throws SQLEx
if (BigQueryJdbcTypeMappings.standardSQLToJavaSqlTypesMapping.containsKey(sqlType)) {
int javaSqlType = BigQueryJdbcTypeMappings.standardSQLToJavaSqlTypesMapping.get(sqlType);
if (javaSqlType != arg2) {
throw new BigQueryJdbcSqlFeatureNotSupportedException(
String.format("Unsupported sql type:%s ", arg2));
BigQueryJdbcSqlFeatureNotSupportedException ex =
new BigQueryJdbcSqlFeatureNotSupportedException(
String.format("Unsupported sql type:%s ", arg2));
LOG.severe(ex, ex.getMessage());
throw ex;
}
} else {
throw new BigQueryJdbcSqlFeatureNotSupportedException(
String.format("parameter sql type not supported: %s", sqlType));
BigQueryJdbcSqlFeatureNotSupportedException ex =
new BigQueryJdbcSqlFeatureNotSupportedException(
String.format("parameter sql type not supported: %s", sqlType));
LOG.severe(ex, ex.getMessage());
throw ex;
}
}

Expand Down
Loading
Loading