Skip to content

Commit 4aa020f

Browse files
abhijeetvgavirtuos
authored andcommitted
Jdbc changes to accomodate block and constraint optimizations. (#59)
* Jdbc changes to accomodate block and constraint optimizations. Also fixes some conversions in writer, boolean and date. * Fix null handling when retrieving rows in JDBC connector. 1. Null handling fix 2. Fix exception handling in row writer. 3. Add informative log lines.
1 parent fcd8928 commit 4aa020f

33 files changed

+229
-90
lines changed

athena-federation-sdk/src/main/java/com/amazonaws/athena/connector/lambda/data/BlockWriter.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,9 @@ interface RowWriter
4343
* are made much simpler by being able to write a small number (<100) rows per call. These often
4444
* relate to batched operators, scan side joins, or field expansions. Writing too many rows
4545
* will result in errors related to Block size management and are implementation specific.
46+
* @throws Exception internal exception.
4647
*/
47-
int writeRows(Block block, int rowNum);
48+
int writeRows(Block block, int rowNum) throws Exception;
4849
}
4950

5051
/**

athena-federation-sdk/src/main/java/com/amazonaws/athena/connector/lambda/data/S3BlockSpiller.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,13 @@ public void writeRows(RowWriter rowWriter)
169169
Block block = inProgressBlock.get();
170170
int rowCount = block.getRowCount();
171171

172-
int rows = rowWriter.writeRows(block, rowCount);
172+
int rows;
173+
try {
174+
rows = rowWriter.writeRows(block, rowCount);
175+
}
176+
catch (Exception ex) {
177+
throw (ex instanceof RuntimeException) ? (RuntimeException) ex : new RuntimeException(ex);
178+
}
173179

174180
if (rows > maxRowsPerCall) {
175181
throw new RuntimeException("Call generated more than " + maxRowsPerCall + "rows. Generating " +

athena-federation-sdk/src/main/java/com/amazonaws/athena/connector/lambda/data/SimpleBlockWriter.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,13 @@ public void writeRows(BlockWriter.RowWriter rowWriter)
5151
{
5252
int rowCount = block.getRowCount();
5353

54-
int rows = rowWriter.writeRows(block, rowCount);
54+
int rows;
55+
try {
56+
rows = rowWriter.writeRows(block, rowCount);
57+
}
58+
catch (Exception ex) {
59+
throw (ex instanceof RuntimeException) ? (RuntimeException) ex : new RuntimeException(ex);
60+
}
5561

5662
if (rows > 0) {
5763
block.setRowCount(rowCount + rows);

athena-federation-sdk/src/main/java/com/amazonaws/athena/connector/lambda/data/writers/GeneratedRowWriter.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ public static RowWriterBuilder newBuilder()
107107
}
108108

109109
public boolean writeRow(Block block, int rowNum, Object context)
110+
throws Exception
110111
{
111112
checkAndRecompile(block);
112113

athena-federation-sdk/src/main/java/com/amazonaws/athena/connector/lambda/data/writers/extractors/BigIntExtractor.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public interface BigIntExtractor
3838
* system row/query from which you need to extract a value.
3939
* @param dst The 'Holder' that you should write your value to and optionally set the isSet flag to > 0 for non-null
4040
* or 0 for null.
41+
* @throws Exception internal exception
4142
*/
42-
void extract(Object context, NullableBigIntHolder dst);
43+
void extract(Object context, NullableBigIntHolder dst) throws Exception;
4344
}

athena-federation-sdk/src/main/java/com/amazonaws/athena/connector/lambda/data/writers/extractors/BitExtractor.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public interface BitExtractor
3838
* system row/query from which you need to extract a value.
3939
* @param dst The 'Holder' that you should write your value to and optionally set the isSet flag to > 0 for non-null
4040
* or 0 for null.
41+
* @throws Exception internal exception
4142
*/
42-
void extract(Object context, NullableBitHolder dst);
43+
void extract(Object context, NullableBitHolder dst) throws Exception;
4344
}

athena-federation-sdk/src/main/java/com/amazonaws/athena/connector/lambda/data/writers/extractors/DateDayExtractor.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public interface DateDayExtractor
3838
* system row/query from which you need to extract a value.
3939
* @param dst The 'Holder' that you should write your value to and optionally set the isSet flag to > 0 for non-null
4040
* or 0 for null.
41+
* @throws Exception internal exception
4142
*/
42-
void extract(Object context, NullableDateDayHolder dst);
43+
void extract(Object context, NullableDateDayHolder dst) throws Exception;
4344
}

athena-federation-sdk/src/main/java/com/amazonaws/athena/connector/lambda/data/writers/extractors/DateMilliExtractor.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public interface DateMilliExtractor
3838
* system row/query from which you need to extract a value.
3939
* @param dst The 'Holder' that you should write your value to and optionally set the isSet flag to > 0 for non-null
4040
* or 0 for null.
41+
* @throws Exception internal exception
4142
*/
42-
void extract(Object context, NullableDateMilliHolder dst);
43+
void extract(Object context, NullableDateMilliHolder dst) throws Exception;
4344
}

athena-federation-sdk/src/main/java/com/amazonaws/athena/connector/lambda/data/writers/extractors/DecimalExtractor.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public interface DecimalExtractor
3838
* system row/query from which you need to extract a value.
3939
* @param dst The 'Holder' that you should write your value to and optionally set the isSet flag to > 0 for non-null
4040
* or 0 for null.
41+
* @throws Exception internal exception
4142
*/
42-
void extract(Object context, NullableDecimalHolder dst);
43+
void extract(Object context, NullableDecimalHolder dst) throws Exception;
4344
}

athena-federation-sdk/src/main/java/com/amazonaws/athena/connector/lambda/data/writers/extractors/Float4Extractor.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public interface Float4Extractor
3838
* system row/query from which you need to extract a value.
3939
* @param dst The 'Holder' that you should write your value to and optionally set the isSet flag to > 0 for non-null
4040
* or 0 for null.
41+
* @throws Exception internal exception
4142
*/
42-
void extract(Object context, NullableFloat4Holder dst);
43+
void extract(Object context, NullableFloat4Holder dst) throws Exception;
4344
}

0 commit comments

Comments
 (0)