[ https://issues.apache.org/jira/browse/DRILL-7143?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16808294#comment-16808294 ]
ASF GitHub Bot commented on DRILL-7143: --------------------------------------- paul-rogers commented on pull request #1726: DRILL-7143: Support default value for empty columns URL: https://github.com/apache/drill/pull/1726#discussion_r271557253 ########## File path: exec/vector/src/main/java/org/apache/drill/exec/vector/accessor/writer/AbstractFixedWidthWriter.java ########## @@ -93,17 +112,62 @@ protected final int prepareWrite(int writeIndex) { @Override protected final void fillEmpties(final int writeIndex) { final int width = width(); - final int stride = ZERO_BUF.length / width; + final int stride = emptyValue.length / width; int dest = lastWriteIndex + 1; while (dest < writeIndex) { int length = writeIndex - dest; length = Math.min(length, stride); - drillBuf.setBytes(dest * width, ZERO_BUF, 0, length * width); + drillBuf.setBytes(dest * width, emptyValue, 0, length * width); dest += length; } } } + /** + * Base class for writers that use the Java int type as their native + * type. Handles common implicit conversions from other types to int. + */ + public static abstract class BaseIntWriter extends BaseFixedWidthWriter { + + @Override + public final void setLong(final long value) { + try { + // Catches int overflow. Does not catch overflow for smaller types. + setInt(Math.toIntExact(value)); + } catch (final ArithmeticException e) { + throw InvalidConversionError.writeError(schema(), value, e); + } + } + + @Override + public final void setDouble(final double value) { Review comment: Yes, just as setInt() covers TInyInt, SmallInt, Int, UInt1, and UInt2. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Enforce column-level constraints when using a schema > ---------------------------------------------------- > > Key: DRILL-7143 > URL: https://issues.apache.org/jira/browse/DRILL-7143 > Project: Apache Drill > Issue Type: Improvement > Affects Versions: 1.16.0 > Reporter: Paul Rogers > Assignee: Paul Rogers > Priority: Major > Fix For: 1.16.0 > > > The recently added schema framework enforces schema constraints at the table > level. We now wish to add additional constraints at the column level. > * If a column is marked as "strict", then the reader will use the exact type > and mode from the column schema, or fail if it is not possible to do so. > * If a column is marked as required, and provides a default value, then that > value is used instead of 0 if a row is missing a value for that column. > This PR may also contain other fixes the the base functional revealed through > additional testing. -- This message was sent by Atlassian JIRA (v7.6.3#76005)