DRILL-679: Support create table as query (CTAS) (contd.).

Continuation to e19606593f3173d8f82ca3074186e9ca7a960ce2.
Refactoring and align the writer interfaces similar to reader interfaces at the storage and file format level.
DRILL-674: Consider the view/table identifier given in CREATE VIEW/TABLE statements.
Fix hash join functions for variable types to use the correct buffer.
Join order: Use parquet row count as the basis of scan cost. Transform select count(*)/count(columnName) into DirectGroupScan when possible.

Nullable return type for extract function.

Fix a bug in DrillProjectRule. Fix bug in ProjectPrule, set Direction for RelCollation trait.

Set nullable properly for extract function's  return type and 'any' type in view DDL or table field lists.
In Logical rule, use child's trait when convert child to logical.  Propagate traits from child to parent, for Project/Filter etc.

Clean up in TestJdbcDistQuery test case.
DRILL-687: Support selecting Date, Timestamp, Decimal data types from Hive into Drill

Add unit test
DRILL-688: Fix timestamp constant serialization