Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Commit

Permalink
Added "datetime_format" URL parameter to handle jdbc date and time fo…
Browse files Browse the repository at this point in the history
…rmatting with new engine
  • Loading branch information
cip999 committed Aug 22, 2021
1 parent 39380c2 commit 60da9ed
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package com.amazon.opendistroforelasticsearch.sql.sql;

import static com.amazon.opendistroforelasticsearch.sql.legacy.TestsConstants.TEST_INDEX_BANK;
import static com.amazon.opendistroforelasticsearch.sql.legacy.TestsConstants.TEST_INDEX_DATE_TIME;
import static com.amazon.opendistroforelasticsearch.sql.util.MatcherUtils.*;

import com.amazon.opendistroforelasticsearch.sql.legacy.SQLIntegTestCase;
Expand Down Expand Up @@ -56,37 +55,4 @@ public void testAliasInSchema() {
verifySchema(response, schema("account_number", "acc", "long"));
}

@Test
public void testDatetimeFormat1() {
String response = executeQuery(
"SELECT login_time FROM " + TEST_INDEX_DATE_TIME,
"jdbc", "always_include_time");

assertTrue(response.contains("\"2015-01-01 00:00:00\""));
assertTrue(response.contains("\"2015-01-01 12:10:30\""));
assertTrue(response.contains("\"2020-04-08 06:10:30\""));
}

@Test
public void testDatetimeFormat2() {
String response = executeQuery(
"SELECT login_time FROM " + TEST_INDEX_DATE_TIME,
"jdbc", "never_include_time");

assertTrue(response.contains("\"2015-01-01\""));
assertFalse(response.contains("\"2015-01-01 12:10:30\""));
assertTrue(response.contains("\"2020-04-08\""));
}

@Test
public void testDatetimeFormat3() {
String response = executeQuery(
"SELECT login_time FROM " + TEST_INDEX_DATE_TIME,
"jdbc", "include_time_when_nonzero");

assertTrue(response.contains("\"2015-01-01\""));
assertTrue(response.contains("\"2015-01-01 12:10:30\""));
assertTrue(response.contains("\"2020-04-08 06:10:30\""));
}

}
4 changes: 2 additions & 2 deletions integ-test/src/test/resources/datetime.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{"login_time":"2015-01-01"}
{"index":{"_id":"2"}}
{"login_time":"2015-01-01T12:10:30Z"}
//{"index":{"_id":"3"}}
//{"login_time":"1585882955"}
{"index":{"_id":"3"}}
{"login_time":"1585882955"}
{"index":{"_id":"4"}}
{"login_time":"2020-04-08T11:10:30+05:00"}

0 comments on commit 60da9ed

Please sign in to comment.