You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@drill.apache.org by pa...@apache.org on 2015/06/17 22:30:35 UTC

[05/10] drill git commit: DRILL-3216: Part 1--Pre-core code hygiene.

DRILL-3216: Part 1--Pre-core code hygiene.

Many-instance changes:  [DatabaseMetaDataGetColumnsTest]
- Renamed "...opt..." columns and methods to match "...mdrOpt" variables.
- Renamed "...req..." columns and methods to match "...mdrReq" variables.
- Renamed "testRow..." variables to "mdrUnk".
- Added/applied getIntOrNull(...) especially to simplify null cases.
- Put REAL, FLOAT, and DOUBLE in that order (smallest, ~variable, largest).
- (Edited "nullability code" -> "nullability code:".)

Renamed "type" -> "relDataType"; "sqlType" -> "sqlTypeName".
Changed "dfs_test.tmp" -> VIEW_SCHEMA.
Re-aligned query SQL.
Added 2 "final".
Edited 3253 (test plugin) TODOs.
Purged several comments.
Wrapped some lines.


Project: http://git-wip-us.apache.org/repos/asf/drill/repo
Commit: http://git-wip-us.apache.org/repos/asf/drill/commit/b018234f
Tree: http://git-wip-us.apache.org/repos/asf/drill/tree/b018234f
Diff: http://git-wip-us.apache.org/repos/asf/drill/diff/b018234f

Branch: refs/heads/master
Commit: b018234f58a964537403be2c105b516a7c43e27f
Parents: 71082e6
Author: dbarclay <db...@maprtech.com>
Authored: Thu Jun 4 13:48:16 2015 -0700
Committer: Parth Chandra <pa...@apache.org>
Committed: Wed Jun 17 11:46:00 2015 -0700

----------------------------------------------------------------------
 .../drill/exec/store/ischema/Records.java       |   24 +-
 .../org/apache/drill/jdbc/impl/MetaImpl.java    |   20 +-
 .../jdbc/DatabaseMetaDataGetColumnsTest.java    | 1263 ++++++++----------
 3 files changed, 581 insertions(+), 726 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/drill/blob/b018234f/exec/java-exec/src/main/java/org/apache/drill/exec/store/ischema/Records.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/store/ischema/Records.java b/exec/java-exec/src/main/java/org/apache/drill/exec/store/ischema/Records.java
index 39b4f3e..5a9387f 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/store/ischema/Records.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/store/ischema/Records.java
@@ -59,35 +59,35 @@ public class Records {
       this.TABLE_NAME = tableName;
 
       this.COLUMN_NAME = field.getName();
-      RelDataType type = field.getType();
-      SqlTypeName sqlType = type.getSqlTypeName();
+      final RelDataType relDataType = field.getType();
+      final SqlTypeName sqlTypeName = relDataType.getSqlTypeName();
 
       this.ORDINAL_POSITION = field.getIndex();
-      this.IS_NULLABLE = type.isNullable() ? "YES" : "NO";
+      this.IS_NULLABLE = relDataType.isNullable() ? "YES" : "NO";
 
-      if (sqlType == SqlTypeName.ARRAY || sqlType == SqlTypeName.MAP || sqlType == SqlTypeName.ROW) {
+      if (sqlTypeName == SqlTypeName.ARRAY || sqlTypeName == SqlTypeName.MAP || sqlTypeName == SqlTypeName.ROW) {
         // For complex types use SqlTypeName's toString method to display the
         // inside elements.
-        String typeString = type.toString();
+        String typeString = relDataType.toString();
 
         // RelDataType.toString prints "RecordType" for "STRUCT".
-        this.DATA_TYPE = type.toString().replace("RecordType", "STRUCT");
+        this.DATA_TYPE = relDataType.toString().replace("RecordType", "STRUCT");
       } else {
-        this.DATA_TYPE = sqlType.toString();
+        this.DATA_TYPE = sqlTypeName.toString();
       }
 
-      this.NUMERIC_PRECISION_RADIX = (sqlType == SqlTypeName.DECIMAL) ? 10 : -1; // TODO: where do we get radix?
+      this.NUMERIC_PRECISION_RADIX = (sqlTypeName == SqlTypeName.DECIMAL) ? 10 : -1; // TODO: where do we get radix?
 
-      if (sqlType == SqlTypeName.VARCHAR) {
+      if (sqlTypeName == SqlTypeName.VARCHAR) {
         // Max length is stored as precision in Optiq.
-        this.CHARACTER_MAXIMUM_LENGTH = (sqlType.allowsPrec()) ? type.getPrecision() : -1;
+        this.CHARACTER_MAXIMUM_LENGTH = (sqlTypeName.allowsPrec()) ? relDataType.getPrecision() : -1;
         this.NUMERIC_PRECISION = -1;
       } else {
         this.CHARACTER_MAXIMUM_LENGTH = -1;
-        this.NUMERIC_PRECISION = (sqlType.allowsPrec()) ? type.getPrecision() : -1;
+        this.NUMERIC_PRECISION = (sqlTypeName.allowsPrec()) ? relDataType.getPrecision() : -1;
       }
 
-      this.NUMERIC_SCALE = (sqlType.allowsScale())?type.getScale(): -1;
+      this.NUMERIC_SCALE = (sqlTypeName.allowsScale())?relDataType.getScale(): -1;
     }
   }
 

http://git-wip-us.apache.org/repos/asf/drill/blob/b018234f/exec/jdbc/src/main/java/org/apache/drill/jdbc/impl/MetaImpl.java
----------------------------------------------------------------------
diff --git a/exec/jdbc/src/main/java/org/apache/drill/jdbc/impl/MetaImpl.java b/exec/jdbc/src/main/java/org/apache/drill/jdbc/impl/MetaImpl.java
index 7e76ea9..f93f5e3 100644
--- a/exec/jdbc/src/main/java/org/apache/drill/jdbc/impl/MetaImpl.java
+++ b/exec/jdbc/src/main/java/org/apache/drill/jdbc/impl/MetaImpl.java
@@ -57,21 +57,23 @@ class MetaImpl implements Meta {
   /** (Maximum) precision of BIGINT. */
   private static final int PREC_BIGINT   = 19;
 
+  /** Precision of REAL. */
+  // TEMPORARY partial change (corrected to 7 in Part 2):
+  private static final int PREC_REAL   = 15;
   /** Precision of FLOAT. */
   private static final int PREC_FLOAT  =  7;
   /** Precision of DOUBLE. */
   private static final int PREC_DOUBLE = 15;
-  /** Precision of REAL. */
-  private static final int PREC_REAL   = PREC_DOUBLE;
 
   /** Scale of INTEGER types. */
   private static final int SCALE_INTEGRAL = 0;
+  // TEMPORARY partial change (corrected to 7 in Part 2):
+  /** JDBC conventional(?) scale value for REAL. */
+  private static final int SCALE_REAL = 15;
   /** JDBC conventional(?) scale value for FLOAT. */
   private static final int SCALE_FLOAT = 7;
   /** JDBC conventional(?) scale value for DOUBLE. */
   private static final int SCALE_DOUBLE = 15;
-  /** JDBC conventional(?) scale value for REAL. */
-  private static final int SCALE_REAL = SCALE_DOUBLE;
 
   /** (Apparent) maximum precision for starting unit of INTERVAL type. */
   private static final int PREC_INTERVAL_LEAD_MAX = 10;
@@ -360,9 +362,9 @@ class MetaImpl implements Meta {
         //   NUM_PREC_RADIX coordinated)?  INFORMATION_SCHEMA.COLUMNS's value
         //   are supposed to be in bits (per the SQL spec.).  What does JDBC
         //   require and allow?
+        + "\n    WHEN 'REAL'                         THEN " + PREC_REAL
         + "\n    WHEN 'FLOAT'                        THEN " + PREC_FLOAT
         + "\n    WHEN 'DOUBLE'                       THEN " + PREC_DOUBLE
-        + "\n    WHEN 'REAL'                         THEN " + PREC_REAL
 
         // "For character data, ... the length in characters":
         // TODO:  BUG:  DRILL-2459:  For CHARACTER / CHAR, length is not in
@@ -430,9 +432,9 @@ class MetaImpl implements Meta {
         + "\n         'BIGINT'                       THEN " + SCALE_INTEGRAL
         + "\n    WHEN 'DECIMAL', "
         + "\n         'NUMERIC'                      THEN NUMERIC_SCALE "
+        + "\n    WHEN 'REAL'                         THEN " + SCALE_REAL
         + "\n    WHEN 'FLOAT'                        THEN " + SCALE_FLOAT
         + "\n    WHEN 'DOUBLE'                       THEN " + SCALE_DOUBLE
-        + "\n    WHEN 'REAL'                         THEN " + SCALE_REAL
         + "\n    WHEN 'INTERVAL'                     THEN NUMERIC_SCALE "
         + "\n    WHEN 'INTERVAL_YEAR_MONTH'          THEN 0 "
         + "\n    WHEN 'INTERVAL_DAY_TIME'            THEN NUMERIC_SCALE "
@@ -446,9 +448,9 @@ class MetaImpl implements Meta {
         + "\n         'BIGINT'                       THEN " + RADIX_INTEGRAL
         + "\n    WHEN 'DECIMAL', "
         + "\n         'NUMERIC'                      THEN " + RADIX_DECIMAL
-        + "\n    WHEN 'FLOAT', "
-        + "\n         'DOUBLE', "
-        + "\n         'REAL'                         THEN " + RADIX_APPROXIMATE
+        + "\n    WHEN 'REAL', "
+        + "\n         'FLOAT', "
+        + "\n         'DOUBLE'                       THEN " + RADIX_APPROXIMATE
         + "\n    WHEN 'INTERVAL_YEAR_MONTH', "
         + "\n         'INTERVAL_DAY_TIME'            THEN " + RADIX_INTERVAL
         + "\n    ELSE                                     NULL"