30
30
import io .wren .base .dto .Manifest ;
31
31
import io .wren .main .connector .duckdb .DuckDBMetadata ;
32
32
import io .wren .main .validation .ValidationResult ;
33
- import io .wren .main .web .dto .CheckOutputDto ;
34
- import io .wren .main .web .dto .DeployInputDto ;
35
33
import io .wren .main .web .dto .DryPlanDto ;
36
34
import io .wren .main .web .dto .DryPlanDtoV2 ;
37
35
import io .wren .main .web .dto .DuckDBQueryDtoV2 ;
41
39
import io .wren .main .web .dto .PreviewDtoV2 ;
42
40
import io .wren .main .web .dto .QueryAnalysisDto ;
43
41
import io .wren .main .web .dto .QueryResultDto ;
42
+ import io .wren .main .web .dto .SqlAnalysisInputBatchDto ;
44
43
import io .wren .main .web .dto .SqlAnalysisInputDto ;
45
44
import io .wren .main .web .dto .SqlAnalysisInputDtoV2 ;
46
45
import io .wren .main .web .dto .ValidateDto ;
53
52
54
53
import java .io .IOException ;
55
54
import java .util .List ;
56
- import java .util .concurrent .CompletableFuture ;
57
- import java .util .concurrent .ExecutionException ;
58
- import java .util .concurrent .TimeUnit ;
59
- import java .util .concurrent .TimeoutException ;
60
55
61
56
import static com .google .common .net .HttpHeaders .CONTENT_TYPE ;
62
57
import static io .airlift .http .client .JsonBodyGenerator .jsonBodyGenerator ;
@@ -81,11 +76,9 @@ public abstract class RequireWrenServer
81
76
protected HttpClient client ;
82
77
83
78
private static final JsonCodec <ErrorMessageDto > ERROR_CODEC = jsonCodec (ErrorMessageDto .class );
84
- private static final JsonCodec <CheckOutputDto > CHECK_OUTPUT_DTO_CODEC = jsonCodec (CheckOutputDto .class );
85
79
public static final JsonCodec <Manifest > MANIFEST_JSON_CODEC = jsonCodec (Manifest .class );
86
80
private static final JsonCodec <PreviewDto > PREVIEW_DTO_CODEC = jsonCodec (PreviewDto .class );
87
81
private static final JsonCodec <PreviewDtoV2 > PREVIEW_DTO_V2_CODEC = jsonCodec (PreviewDtoV2 .class );
88
- private static final JsonCodec <DeployInputDto > DEPLOY_INPUT_DTO_JSON_CODEC = jsonCodec (DeployInputDto .class );
89
82
private static final JsonCodec <SqlAnalysisInputDto > SQL_ANALYSIS_INPUT_DTO_CODEC = jsonCodec (SqlAnalysisInputDto .class );
90
83
private static final JsonCodec <SqlAnalysisInputDtoV2 > SQL_ANALYSIS_INPUT_DTO_V2_CODEC = jsonCodec (SqlAnalysisInputDtoV2 .class );
91
84
private static final JsonCodec <ConfigManager .ConfigEntry > CONFIG_ENTRY_JSON_CODEC = jsonCodec (ConfigManager .ConfigEntry .class );
@@ -100,6 +93,8 @@ public abstract class RequireWrenServer
100
93
private static final JsonCodec <List <QueryAnalysisDto >> QUERY_ANALYSIS_DTO_LIST_CODEC = listJsonCodec (QueryAnalysisDto .class );
101
94
private static final JsonCodec <DuckDBQueryDtoV2 > DUCKDB_QUERY_DTO_V2_JSON_CODEC = jsonCodec (DuckDBQueryDtoV2 .class );
102
95
private static final JsonCodec <DuckDBValidationDtoV2 > DUCKDB_VALIDATION_DTO_V2_JSON_CODEC = jsonCodec (DuckDBValidationDtoV2 .class );
96
+ private static final JsonCodec <SqlAnalysisInputBatchDto > SQL_ANALYSIS_INPUT_BATCH_DTO_CODEC = jsonCodec (SqlAnalysisInputBatchDto .class );
97
+ private static final JsonCodec <List <List <QueryAnalysisDto >>> QUERY_ANALYSIS_DTO_LIST_LIST_CODEC = listJsonCodec (listJsonCodec (QueryAnalysisDto .class ));
103
98
104
99
public RequireWrenServer () {}
105
100
@@ -299,78 +294,34 @@ protected void validateDuckDBV2(String ruleName, DuckDBValidationDtoV2 duckDBVal
299
294
}
300
295
}
301
296
302
- protected void deployMDL (DeployInputDto dto )
303
- {
304
- Request request = preparePost ()
305
- .setUri (server ().getHttpServerBasedUrl ().resolve ("/v1/mdl/deploy" ))
306
- .setHeader (CONTENT_TYPE , "application/json" )
307
- .setBodyGenerator (jsonBodyGenerator (DEPLOY_INPUT_DTO_JSON_CODEC , dto ))
308
- .build ();
309
-
310
- StringResponseHandler .StringResponse response = executeHttpRequest (request , createStringResponseHandler ());
311
- if (response .getStatusCode () != 202 ) {
312
- getWebApplicationException (response );
313
- }
314
- }
315
-
316
- protected Manifest getCurrentManifest ()
317
- {
318
- Request request = prepareGet ()
319
- .setUri (server ().getHttpServerBasedUrl ().resolve ("/v1/mdl" ))
320
- .build ();
321
-
322
- StringResponseHandler .StringResponse response = executeHttpRequest (request , createStringResponseHandler ());
323
- if (response .getStatusCode () != 200 ) {
324
- getWebApplicationException (response );
325
- }
326
- return MANIFEST_JSON_CODEC .fromJson (response .getBody ());
327
- }
328
-
329
- protected CheckOutputDto getDeployStatus ()
297
+ protected List <QueryAnalysisDto > getSqlAnalysis (SqlAnalysisInputDto inputDto )
330
298
{
331
299
Request request = prepareGet ()
332
- .setUri (server ().getHttpServerBasedUrl ().resolve ("/v1/mdl/status" ))
300
+ .setUri (server ().getHttpServerBasedUrl ().resolve ("/v1/analysis/sql" ))
301
+ .setHeader (CONTENT_TYPE , "application/json" )
302
+ .setBodyGenerator (jsonBodyGenerator (SQL_ANALYSIS_INPUT_DTO_CODEC , inputDto ))
333
303
.build ();
334
304
335
305
StringResponseHandler .StringResponse response = executeHttpRequest (request , createStringResponseHandler ());
336
306
if (response .getStatusCode () != 200 ) {
337
307
getWebApplicationException (response );
338
308
}
339
- return CHECK_OUTPUT_DTO_CODEC .fromJson (response .getBody ());
340
- }
341
-
342
- protected void waitUntilReady ()
343
- throws ExecutionException , InterruptedException , TimeoutException
344
- {
345
- CompletableFuture .runAsync (() -> {
346
- while (true ) {
347
- CheckOutputDto checkOutputDto = getDeployStatus ();
348
- if (checkOutputDto .getStatus () == CheckOutputDto .Status .READY ) {
349
- break ;
350
- }
351
- try {
352
- Thread .sleep (1000 );
353
- }
354
- catch (InterruptedException e ) {
355
- throw new AssertionError ("Status doesn't change to READY" , e );
356
- }
357
- }
358
- }).get (60 , TimeUnit .SECONDS );
309
+ return QUERY_ANALYSIS_DTO_LIST_CODEC .fromJson (response .getBody ());
359
310
}
360
311
361
- protected List <QueryAnalysisDto > getSqlAnalysis ( SqlAnalysisInputDto inputDto )
312
+ protected List <List < QueryAnalysisDto >> getSqlAnalysisBatch ( SqlAnalysisInputBatchDto inputBatchDto )
362
313
{
363
314
Request request = prepareGet ()
364
- .setUri (server ().getHttpServerBasedUrl ().resolve ("/v1 /analysis/sql " ))
315
+ .setUri (server ().getHttpServerBasedUrl ().resolve ("/v2 /analysis/sqls " ))
365
316
.setHeader (CONTENT_TYPE , "application/json" )
366
- .setBodyGenerator (jsonBodyGenerator (SQL_ANALYSIS_INPUT_DTO_CODEC , inputDto ))
317
+ .setBodyGenerator (jsonBodyGenerator (SQL_ANALYSIS_INPUT_BATCH_DTO_CODEC , inputBatchDto ))
367
318
.build ();
368
319
369
320
StringResponseHandler .StringResponse response = executeHttpRequest (request , createStringResponseHandler ());
370
321
if (response .getStatusCode () != 200 ) {
371
322
getWebApplicationException (response );
372
323
}
373
- return QUERY_ANALYSIS_DTO_LIST_CODEC .fromJson (response .getBody ());
324
+ return QUERY_ANALYSIS_DTO_LIST_LIST_CODEC .fromJson (response .getBody ());
374
325
}
375
326
376
327
protected List <QueryAnalysisDto > getSqlAnalysisV2 (SqlAnalysisInputDtoV2 inputDto )
0 commit comments