Package org.apache.drill.exec.physical.impl.scan.convert
ValuesWriter
interface. The classes here wrap a
ScalarWriter
: either a simple column, or the scalar portion of
an array column.
The converters sit outside of the column writer hierarchy. In the
most general case, a batch reader uses a "column adapter" to convert
from some source-specific input format such as a JDBC ResultSet
.
In this case, the reader maintains a "row format": the set of column
adapters that make up the row.
The classes here handle a special case: when the reader just needs the standard Java types. These classes allow a batch reader to intermix "plain" column writers and column conversions in a "row format". This in turn, ensures that there is no extra function call overhead when no conversion is needed.
Provides a mapping from input to output (vector) type. Handles implicit conversions (those done by the column writer itself) and explicit conversions for the Java string notation for various types. Readers must provide custom conversions or specialized formats.
Type-narrowing operations are supported by the column writers using "Java semantics". Long-to-int overflow is caught, double-to-long conversion sets the maximum or minimum long values, Double-to-int will overflow (on the int conversion.) Messy, but the goal is not to handle invalid data, rather it is to provide convenience for valid data.
The semantics of invalid conversions can be refined (set to null or throw an exception) without affecting the behavior of queries with valid data.
The provided conversions all handle the normal cases. Exceptional case (overflow, ambiguous formats) are handled according to Java rules.
The StandardConversions
class defines the types of conversions
needed:
- None: Converting from a type to itself.
- Implicit: Conversion is done by the column writers, such as converting from an INT to a SMALLINT.
- Explicit: Requires a converter. If an unambiguous conversion is possible, that converter should occur here. If conversion is ambiguous, or a reader needs to support a special format, then the reader can add custom conversions for these cases.
Would be good to validate each conversion against the corresponding CAST operation. In an ideal world, all conversions, normal and exceptional, will work the same as either a CAST (where the operations is handled by the Project operator via code generation) and the standard conversions.
-
ClassDescriptionAbstract class for string-to-something conversions.Base class for any kind of column converter.Convert a VARCHAR column to an BIT column following the Java rules for parsing Boolean values, then using 1 if the boolean is true, 0 if false.Convert a VARCHAR column to an DATE column following the Java rules for parsing a date time, optionally using the formatter provided in the column schema.Convert a VARCHAR column to an decimal column following the Java rules for parsing integers (i.e.Convert a VARCHAR column to a DOUBLE column following the Java rules for parsing doubles (i.e.Convert a VARCHAR column to an INT column following the Java rules for parsing integers (i.e.Convert a VARCHAR column to an INTERVAL column following the Java rules for parsing a period.Convert a VARCHAR column to an BIGINT column following the Java rules for parsing longs (i.e.Convert a VARCHAR column to an TIME column following the Java rules for parsing a date time, optionally using the formatter provided in the column schema.Convert a VARCHAR column to an TIMESTAMP column following the Java rules for parsing a date time, optionally using the formatter provided in the column schema.Base class for Java type-based conversion.Factory for standard conversions as outlined in the package header.Definition of a conversion including conversion type and the standard conversion class (if available.)Indicates the type of conversion needed.