Skip to content

Commit 01a89a4

Browse files
authored
test: Add general end-to-end test cases to test WHERE clause. (#66)
1 parent a50bfef commit 01a89a4

File tree

1 file changed

+52
-1
lines changed

1 file changed

+52
-1
lines changed

presto-native-execution/src/test/java/com/facebook/presto/nativeworker/TestPrestoNativeClpGeneralQueries.java

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,12 @@ public void test()
105105
// H2QueryRunner currently can't change the timestamp format, and the default timestamp
106106
// format of Presto is different, so for now we have to manually format the timestamp
107107
// field.
108+
109+
// Test SELECT all
108110
assertQuery(
109111
format("SELECT" +
110112
" msg," +
111-
" format_datetime(t.dollar_sign_date, 'yyyy-MM-dd HH:mm:ss.SSS')," +
113+
" FORMAT_DATETIME(t.dollar_sign_date, 'yyyy-MM-dd HH:mm:ss.SSS')," +
112114
" id," +
113115
" attr," +
114116
" tags" +
@@ -126,6 +128,55 @@ public void test()
126128
" ARRAY[ARRAY[NULL]]" +
127129
" ]," +
128130
" NULL");
131+
132+
// Test WHERE clause with numeric comparison
133+
assertQuery(
134+
format("SELECT" +
135+
" msg," +
136+
" FORMAT_DATETIME(t.dollar_sign_date, 'yyyy-MM-dd HH:mm:ss.SSS')," +
137+
" id," +
138+
" attr," +
139+
" tags" +
140+
" FROM %s" +
141+
" WHERE t.dollar_sign_date > FROM_UNIXTIME(1679441694.576)" +
142+
" ORDER BY id" +
143+
" LIMIT 1", DEFAULT_TABLE_NAME),
144+
"SELECT" +
145+
" 'There were no users to pin, not starting tracker thread'," +
146+
" TIMESTAMP '2023-03-22 12:34:55.821'," +
147+
" 20227," +
148+
" ARRAY[" +
149+
" NULL," +
150+
" ARRAY[ARRAY[ARRAY[ARRAY[ARRAY[NULL]]]]]," +
151+
" NULL," +
152+
" ARRAY[ARRAY[NULL]]" +
153+
" ]," +
154+
" NULL");
155+
156+
// Test WHERE clause with string matching
157+
assertQuery(
158+
format("SELECT" +
159+
" msg," +
160+
" FORMAT_DATETIME(t.dollar_sign_date, 'yyyy-MM-dd HH:mm:ss.SSS')," +
161+
" id," +
162+
" attr," +
163+
" tags" +
164+
" FROM %s" +
165+
" WHERE t.dollar_sign_date > FROM_UNIXTIME(1679441694.576)" +
166+
" AND msg LIKE '%%user%%'" +
167+
" ORDER BY id" +
168+
" LIMIT 1", DEFAULT_TABLE_NAME),
169+
"SELECT" +
170+
" 'There were no users to pin, not starting tracker thread'," +
171+
" TIMESTAMP '2023-03-22 12:34:55.821'," +
172+
" 20227," +
173+
" ARRAY[" +
174+
" NULL," +
175+
" ARRAY[ARRAY[ARRAY[ARRAY[ARRAY[NULL]]]]]," +
176+
" NULL," +
177+
" ARRAY[ARRAY[NULL]]" +
178+
" ]," +
179+
" NULL");
129180
}
130181

131182
@AfterTest

0 commit comments

Comments
 (0)