50
50
"expression" : "TO_TIMESTAMP('2024-01-01 23:59:59', 'YYYY-MM-DD HH24:MI:SS')" ,
51
51
"type" : "timestamp" ,
52
52
},
53
+ {
54
+ "name" : "timestamptz" ,
55
+ "expression" : "TO_TIMESTAMP_TZ( '2024-01-01 23:59:59.000000 +00:00', 'YYYY-MM-DD HH24:MI:SS.FF6 TZH:TZM')" ,
56
+ "type" : "timestamp" ,
57
+ },
53
58
{
54
59
"name" : "test_null_time" ,
55
60
"expression" : "CAST(NULL AS TIMESTAMP)" ,
@@ -103,6 +108,33 @@ async def test_query(client, manifest_str, oracle: OracleDbContainer):
103
108
},
104
109
)
105
110
assert response .status_code == 200
111
+ result = response .json ()
112
+ assert len (result ["columns" ]) == len (manifest ["models" ][0 ]["columns" ])
113
+ assert len (result ["data" ]) == 1
114
+ assert result ["data" ][0 ] == [
115
+ 1 ,
116
+ 370 ,
117
+ "O" ,
118
+ "172799.49" ,
119
+ "1996-01-02" ,
120
+ "1_370" ,
121
+ "2024-01-01 23:59:59.000000" ,
122
+ "2024-01-01 23:59:59.000000 UTC" ,
123
+ None ,
124
+ "616263" ,
125
+ ]
126
+ assert result ["dtypes" ] == {
127
+ "orderkey" : "int64" ,
128
+ "custkey" : "int64" ,
129
+ "orderstatus" : "object" ,
130
+ "totalprice" : "object" ,
131
+ "orderdate" : "object" ,
132
+ "order_cust_key" : "object" ,
133
+ "timestamp" : "object" ,
134
+ "timestamptz" : "object" ,
135
+ "test_null_time" : "datetime64[ns]" ,
136
+ "blob_column" : "object" ,
137
+ }
106
138
107
139
108
140
async def test_query_with_connection_url (
@@ -125,6 +157,72 @@ async def test_query_with_connection_url(
125
157
assert result ["dtypes" ] is not None
126
158
127
159
160
+ async def test_query_without_manifest (client , oracle : OracleDbContainer ):
161
+ connection_info = _to_connection_info (oracle )
162
+ response = await client .post (
163
+ url = f"{ base_url } /query" ,
164
+ json = {
165
+ "connectionInfo" : connection_info ,
166
+ "sql" : 'SELECT * FROM "Orders" LIMIT 1' ,
167
+ },
168
+ )
169
+ assert response .status_code == 422
170
+ result = response .json ()
171
+ assert result ["detail" ][0 ] is not None
172
+ assert result ["detail" ][0 ]["type" ] == "missing"
173
+ assert result ["detail" ][0 ]["loc" ] == ["body" , "manifestStr" ]
174
+ assert result ["detail" ][0 ]["msg" ] == "Field required"
175
+
176
+
177
+ async def test_query_without_sql (client , manifest_str , oracle : OracleDbContainer ):
178
+ connection_info = _to_connection_info (oracle )
179
+ response = await client .post (
180
+ url = f"{ base_url } /query" ,
181
+ json = {
182
+ "connectionInfo" : connection_info ,
183
+ "manifestStr" : manifest_str ,
184
+ },
185
+ )
186
+ assert response .status_code == 422
187
+ result = response .json ()
188
+ assert result ["detail" ][0 ] is not None
189
+ assert result ["detail" ][0 ]["type" ] == "missing"
190
+ assert result ["detail" ][0 ]["loc" ] == ["body" , "sql" ]
191
+ assert result ["detail" ][0 ]["msg" ] == "Field required"
192
+
193
+
194
+ async def test_query_without_connection_info (
195
+ client , manifest_str , oracle : OracleDbContainer
196
+ ):
197
+ response = await client .post (
198
+ url = f"{ base_url } /query" ,
199
+ json = {
200
+ "manifestStr" : manifest_str ,
201
+ "sql" : 'SELECT * FROM "Orders" LIMIT 1' ,
202
+ },
203
+ )
204
+ assert response .status_code == 422
205
+ result = response .json ()
206
+ assert result ["detail" ][0 ] is not None
207
+ assert result ["detail" ][0 ]["type" ] == "missing"
208
+ assert result ["detail" ][0 ]["loc" ] == ["body" , "connectionInfo" ]
209
+ assert result ["detail" ][0 ]["msg" ] == "Field required"
210
+
211
+
212
+ async def test_query_with_dry_run (client , manifest_str , oracle : OracleDbContainer ):
213
+ connection_info = _to_connection_info (oracle )
214
+ response = await client .post (
215
+ url = f"{ base_url } /query" ,
216
+ params = {"dryRun" : True },
217
+ json = {
218
+ "connectionInfo" : connection_info ,
219
+ "manifestStr" : manifest_str ,
220
+ "sql" : 'SELECT * FROM "Orders" LIMIT 1' ,
221
+ },
222
+ )
223
+ assert response .status_code == 204
224
+
225
+
128
226
def _to_connection_info (oracle : OracleDbContainer ):
129
227
# We can't use oracle.user, oracle.password, oracle.dbname here
130
228
# since these values are None at this point
0 commit comments