Cleanup, and fix minor timezone issue in a test.
diff --git a/src/main/java/net/hydromatic/optiq/impl/csv/CsvEnumerator.java b/src/main/java/net/hydromatic/optiq/impl/csv/CsvEnumerator.java
index f1f3fac..bceb8c3 100644
--- a/src/main/java/net/hydromatic/optiq/impl/csv/CsvEnumerator.java
+++ b/src/main/java/net/hydromatic/optiq/impl/csv/CsvEnumerator.java
@@ -40,7 +40,6 @@
private static final FastDateFormat TIME_FORMAT_TIMESTAMP;
static {
-
TimeZone gmt = TimeZone.getTimeZone("GMT");
TIME_FORMAT_DATE = FastDateFormat.getInstance("yyyy-MM-dd", gmt);
TIME_FORMAT_TIME = FastDateFormat.getInstance("hh:mm:ss", gmt);
@@ -112,9 +111,6 @@
return string;
}
switch (fieldType) {
- default:
- case STRING:
- return string;
case BOOLEAN:
if (string.length() == 0) {
return null;
@@ -154,26 +150,22 @@
if (string.length() == 0) {
return null;
}
-
try {
Date date = TIME_FORMAT_DATE.parse(string);
return new java.sql.Date(date.getTime());
} catch (ParseException e) {
return null;
}
-
case TIME:
if (string.length() == 0) {
return null;
}
-
try {
Date date = TIME_FORMAT_TIME.parse(string);
return new java.sql.Time(date.getTime());
} catch (ParseException e) {
return null;
}
-
case TIMESTAMP:
if (string.length() == 0) {
return null;
@@ -184,12 +176,14 @@
} catch (ParseException e) {
return null;
}
+ case STRING:
+ default:
+ return string;
}
}
}
private static class ArrayRowConverter extends RowConverter {
-
private final CsvFieldType[] fieldTypes;
private final int[] fields;
@@ -209,7 +203,6 @@
}
private static class SingleColumnRowConverter extends RowConverter {
-
private final CsvFieldType fieldType;
private final int fieldIndex;
@@ -222,7 +215,6 @@
return convert(fieldType, strings[fieldIndex]);
}
}
-
}
// End CsvEnumerator.java
diff --git a/src/main/java/net/hydromatic/optiq/impl/csv/CsvFieldType.java b/src/main/java/net/hydromatic/optiq/impl/csv/CsvFieldType.java
index 12e94d2..bbcf361 100644
--- a/src/main/java/net/hydromatic/optiq/impl/csv/CsvFieldType.java
+++ b/src/main/java/net/hydromatic/optiq/impl/csv/CsvFieldType.java
@@ -34,7 +34,7 @@
* makes it easier to write SQL.</p>
*/
enum CsvFieldType {
- STRING(null, String.class, "string"),
+ STRING(String.class, "string"),
BOOLEAN(Primitive.BOOLEAN),
BYTE(Primitive.BYTE),
CHAR(Primitive.CHAR),
@@ -43,11 +43,10 @@
LONG(Primitive.LONG),
FLOAT(Primitive.FLOAT),
DOUBLE(Primitive.DOUBLE),
- DATE(null, java.sql.Date.class, "date"),
- TIME(null, java.sql.Time.class, "time"),
- TIMESTAMP(null, java.sql.Timestamp.class, "timestamp");
+ DATE(java.sql.Date.class, "date"),
+ TIME(java.sql.Time.class, "time"),
+ TIMESTAMP(java.sql.Timestamp.class, "timestamp");
- private final Primitive primitive;
private final Class clazz;
private final String simpleName;
@@ -61,12 +60,10 @@
}
CsvFieldType(Primitive primitive) {
- this(primitive, primitive.boxClass,
- primitive.primitiveClass.getSimpleName());
+ this(primitive.boxClass, primitive.primitiveClass.getSimpleName());
}
- CsvFieldType(Primitive primitive, Class clazz, String simpleName) {
- this.primitive = primitive;
+ CsvFieldType(Class clazz, String simpleName) {
this.clazz = clazz;
this.simpleName = simpleName;
}
diff --git a/src/test/java/net/hydromatic/optiq/test/CsvTest.java b/src/test/java/net/hydromatic/optiq/test/CsvTest.java
index 5847c8b..6c5bbe2 100644
--- a/src/test/java/net/hydromatic/optiq/test/CsvTest.java
+++ b/src/test/java/net/hydromatic/optiq/test/CsvTest.java
@@ -222,7 +222,7 @@
buf.append(sep)
.append(resultSet.getMetaData().getColumnLabel(i))
.append("=")
- .append(resultSet.getObject(i));
+ .append(resultSet.getString(i));
sep = "; ";
}
result.add(toLinux(buf.toString()));
@@ -268,17 +268,13 @@
"EMPNO=100; SLACKER=true");
}
- @Test
- public void testDateType() throws SQLException {
-
+ @Test public void testDateType() throws SQLException {
Properties info = new Properties();
info.put("model", "target/test-classes/bug.json");
- Connection connection = DriverManager
- .getConnection("jdbc:optiq:", info);
+ Connection connection = DriverManager.getConnection("jdbc:optiq:", info);
try {
-
ResultSet res = connection.getMetaData().getColumns(null, null,
"DATE", "JOINEDAT");
res.next();
@@ -318,8 +314,6 @@
} finally {
connection.close();
}
-
-
}
}