Github user jiang-wu commented on a diff in the pull request: https://github.com/apache/drill/pull/1184#discussion_r180925699 --- Diff: exec/vector/src/main/codegen/templates/FixedValueVectors.java --- @@ -509,15 +509,15 @@ public long getTwoAsLong(int index) { public ${friendlyType} getObject(int index) { org.joda.time.DateTime date = new org.joda.time.DateTime(get(index), org.joda.time.DateTimeZone.UTC); date = date.withZoneRetainFields(org.joda.time.DateTimeZone.getDefault()); - return date; + return new java.sql.Date(date.getMillis()); --- End diff -- Good point. Someone with deeper knowledge should take a look. As far as I can tell, I think the problem with SqlAccessor is that it uses the vector type to know whether to invoke getDate() vs getTimestamp(). However, such vector type knowledge is not there when complex type such as List and Map are materialized in memory to form Java JsonStringArrayList and JsonStringHashMap. In https://issues.apache.org/jira/browse/DRILL-6242, the example describes this scenario: `select t.context.`date`, t.context from test t;` where the `date` field is inside a Map type. And we select the field by itself as well as select the Map on the same query. This query returns: `+--------+---------+ ` `| EXPR$0 | context | ` `+--------+---------+ ` `| 2018-03-13 | {"date":{"dayOfYear":72,"year":2018, ... |` One can see that the first column shows the date in the right type. But the same date is shown as a different type inside the Map. In the vector package, when reading the [List|Map]Vector, the code produces its nested member values via the generic method "getObject()". Since all three vector type returned the same DataObject type as the representation, there are no distinction. For the type information to be carried within the List | Map, it would seem that the value should be of distinct types. These can be java.sql.[Date|Time|Timestamp] or some other [Date|Time|Timestamp] classes.
---