You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: datafusion/sqllogictest/test_files/expr.slt
+110-4Lines changed: 110 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -2324,28 +2324,134 @@ host3 3.3
2324
2324
2325
2325
# can have an aggregate function with an inner CASE WHEN
2326
2326
query TR
2327
-
select t2."struct(t1.time,t1.load1,t1.load2,t1.host)"['c3'] as host, sum((case when t2."struct(t1.time,t1.load1,t1.load2,t1.host)"['c3'] is not null then t2."struct(t1.time,t1.load1,t1.load2,t1.host)" end)['c2']) from (select struct(time,load1,load2,host) from t1) t2 where t2."struct(t1.time,t1.load1,t1.load2,t1.host)"['c3'] IS NOT NULL group by t2."struct(t1.time,t1.load1,t1.load2,t1.host)"['c3'] order by host;
2327
+
select
2328
+
t2.server_host as host,
2329
+
sum((
2330
+
case when t2.server_host is not null
2331
+
then t2.server_load2
2332
+
end
2333
+
))
2334
+
from (
2335
+
select
2336
+
struct(time,load1,load2,host)['c2'] as server_load2,
2337
+
struct(time,load1,load2,host)['c3'] as server_host
2338
+
from t1
2339
+
) t2
2340
+
where server_host IS NOT NULL
2341
+
group by server_host order by host;
2328
2342
----
2329
2343
host1 101
2330
2344
host2 202
2331
2345
host3 303
2332
2346
2347
+
# TODO: Issue tracked in https://github.com/apache/datafusion/issues/10364
2348
+
query error
2349
+
select
2350
+
t2.server['c3'] as host,
2351
+
sum((
2352
+
case when t2.server['c3'] is not null
2353
+
then t2.server['c2']
2354
+
end
2355
+
))
2356
+
from (
2357
+
select
2358
+
struct(time,load1,load2,host) as server
2359
+
from t1
2360
+
) t2
2361
+
where t2.server['c3'] IS NOT NULL
2362
+
group by t2.server['c3'] order by host;
2363
+
2333
2364
# can have 2 projections with aggr(short_circuited), with different short-circuited expr
2334
2365
query TRR
2335
-
select t2."struct(t1.time,t1.load1,t1.load2,t1.host)"['c3'] as host, sum(coalesce(t2."struct(t1.time,t1.load1,t1.load2,t1.host)")['c1']), sum((case when t2."struct(t1.time,t1.load1,t1.load2,t1.host)"['c3'] is not null then t2."struct(t1.time,t1.load1,t1.load2,t1.host)" end)['c2']) from (select struct(time,load1,load2,host) from t1) t2 where t2."struct(t1.time,t1.load1,t1.load2,t1.host)"['c3'] IS NOT NULL group by t2."struct(t1.time,t1.load1,t1.load2,t1.host)"['c3'] order by host;
2366
+
select
2367
+
t2.server_host as host,
2368
+
sum(coalesce(server_load1)),
2369
+
sum((
2370
+
case when t2.server_host is not null
2371
+
then t2.server_load2
2372
+
end
2373
+
))
2374
+
from (
2375
+
select
2376
+
struct(time,load1,load2,host)['c1'] as server_load1,
2377
+
struct(time,load1,load2,host)['c2'] as server_load2,
2378
+
struct(time,load1,load2,host)['c3'] as server_host
2379
+
from t1
2380
+
) t2
2381
+
where server_host IS NOT NULL
2382
+
group by server_host order by host;
2336
2383
----
2337
2384
host1 1.1 101
2338
2385
host2 2.2 202
2339
2386
host3 3.3 303
2340
2387
2341
-
# can have 2 projections with aggr(short_circuited), with the same short-circuited expr (e.g. CASE WHEN)
2388
+
# TODO: Issue tracked in https://github.com/apache/datafusion/issues/10364
2389
+
query error
2390
+
select
2391
+
t2.server['c3'] as host,
2392
+
sum(coalesce(server['c1'])),
2393
+
sum((
2394
+
case when t2.server['c3'] is not null
2395
+
then t2.server['c2']
2396
+
end
2397
+
))
2398
+
from (
2399
+
select
2400
+
struct(time,load1,load2,host) as server,
2401
+
from t1
2402
+
) t2
2403
+
where server_host IS NOT NULL
2404
+
group by server_host order by host;
2405
+
2342
2406
query TRR
2343
-
select t2."struct(t1.time,t1.load1,t1.load2,t1.host)"['c3'] as host, sum((case when t2."struct(t1.time,t1.load1,t1.load2,t1.host)"['c3'] is not null then t2."struct(t1.time,t1.load1,t1.load2,t1.host)" end)['c1']), sum((case when t2."struct(t1.time,t1.load1,t1.load2,t1.host)"['c3'] is not null then t2."struct(t1.time,t1.load1,t1.load2,t1.host)" end)['c2']) from (select struct(time,load1,load2,host) from t1) t2 where t2."struct(t1.time,t1.load1,t1.load2,t1.host)"['c3'] IS NOT NULL group by t2."struct(t1.time,t1.load1,t1.load2,t1.host)"['c3'] order by host;
2407
+
select
2408
+
t2.server_host as host,
2409
+
sum((
2410
+
case when t2.server_host is not null
2411
+
then server_load1
2412
+
end
2413
+
)),
2414
+
sum((
2415
+
case when server_host is not null
2416
+
then server_load2
2417
+
end
2418
+
))
2419
+
from (
2420
+
select
2421
+
struct(time,load1,load2,host)['c1'] as server_load1,
2422
+
struct(time,load1,load2,host)['c2'] as server_load2,
2423
+
struct(time,load1,load2,host)['c3'] as server_host
2424
+
from t1
2425
+
) t2
2426
+
where server_host IS NOT NULL
2427
+
group by server_host order by host;
2344
2428
----
2345
2429
host1 1.1 101
2346
2430
host2 2.2 202
2347
2431
host3 3.3 303
2348
2432
2433
+
# TODO: Issue tracked in https://github.com/apache/datafusion/issues/10364
2434
+
query error
2435
+
select
2436
+
t2.server['c3'] as host,
2437
+
sum((
2438
+
case when t2.server['c3'] is not null
2439
+
then t2.server['c1']
2440
+
end
2441
+
)),
2442
+
sum((
2443
+
case when t2.server['c3'] is not null
2444
+
then t2.server['c2']
2445
+
end
2446
+
))
2447
+
from (
2448
+
select
2449
+
struct(time,load1,load2,host) as server
2450
+
from t1
2451
+
) t2
2452
+
where t2.server['c3'] IS NOT NULL
2453
+
group by t2.server['c3'] order by host;
2454
+
2349
2455
# can have 2 projections with aggr(short_circuited), with the same short-circuited expr (e.g. coalesce)
2350
2456
query TRR
2351
2457
select t2."struct(t1.time,t1.load1,t1.load2,t1.host)"['c3'] as host, sum(coalesce(t2."struct(t1.time,t1.load1,t1.load2,t1.host)")['c1']), sum(coalesce(t2."struct(t1.time,t1.load1,t1.load2,t1.host)")['c2']) from (select struct(time,load1,load2,host) from t1) t2 where t2."struct(t1.time,t1.load1,t1.load2,t1.host)"['c3'] IS NOT NULL group by t2."struct(t1.time,t1.load1,t1.load2,t1.host)"['c3'] order by host;
0 commit comments