mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-01-10 15:22:56 +00:00
* fix: print the output message of the error in admin fn macro (#6994) Signed-off-by: evenyag <realevenyag@gmail.com> Signed-off-by: discord9 <discord9@163.com> * fix: make EXPIRE (keyword) parsing case-insensitive, when creating flow (#6997) fix: make EXPIRE keyword case-insensitive in CREATE FLOW parser Signed-off-by: Shyamnatesan <shyamnatesan21@gmail.com> Signed-off-by: discord9 <discord9@163.com> * fix: promql range function has incorrect timestamps (#7006) * fix: promql range function has incorrect timestamps Signed-off-by: Ruihang Xia <waynestxia@gmail.com> * simplify Signed-off-by: Ruihang Xia <waynestxia@gmail.com> --------- Signed-off-by: Ruihang Xia <waynestxia@gmail.com> Signed-off-by: discord9 <discord9@163.com> * fix: incorrect timestamp resolution in information_schema.partitions table (#7004) * fix: incorrect timestamp resolution in information_schema.partitions table Signed-off-by: Ruihang Xia <waynestxia@gmail.com> * use second for all fields in partitions table Signed-off-by: Ruihang Xia <waynestxia@gmail.com> * update sqlness result Signed-off-by: Ruihang Xia <waynestxia@gmail.com> --------- Signed-off-by: Ruihang Xia <waynestxia@gmail.com> Signed-off-by: discord9 <discord9@163.com> * fix: match promql column reference in case sensitive way (#7013) Signed-off-by: Ruihang Xia <waynestxia@gmail.com> Signed-off-by: discord9 <discord9@163.com> * fix: group by expr not as column in step aggr (#7008) * fix: group by expr not as column Signed-off-by: discord9 <discord9@163.com> * test: dist analyzer date_bin Signed-off-by: discord9 <discord9@163.com> * ???fix wip Signed-off-by: discord9 <discord9@163.com> * fix: deduce using correct input fields Signed-off-by: discord9 <discord9@163.com> * refactor: clearer wrapper Signed-off-by: discord9 <discord9@163.com> * chore: update sqlness Signed-off-by: discord9 <discord9@163.com> * chore: per review Signed-off-by: discord9 <discord9@163.com> * chore: per review Signed-off-by: discord9 <discord9@163.com> * chore: rm todo Signed-off-by: discord9 <discord9@163.com> --------- Signed-off-by: discord9 <discord9@163.com> * fix: skip placeholder when partition columns (#7020) Signed-off-by: discord9 <discord9@163.com> * chore: add function for getting started on metasrv (#7022) Signed-off-by: shuiyisong <xixing.sys@gmail.com> Signed-off-by: discord9 <discord9@163.com> * fix: not step when aggr have order by/filter (#7015) * fix: not applied Signed-off-by: discord9 <discord9@163.com> * chore: per review Signed-off-by: discord9 <discord9@163.com> * test: confirm order by not push down Signed-off-by: discord9 <discord9@163.com> --------- Signed-off-by: discord9 <discord9@163.com> * feat: supports expression in TQL params (#7014) * feat: supports expression in TQL params Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * chore: by cr comments Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * chore: comment Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * chore: by cr comments Signed-off-by: Dennis Zhuang <killme2008@gmail.com> --------- Signed-off-by: Dennis Zhuang <killme2008@gmail.com> Signed-off-by: discord9 <discord9@163.com> * feat: update dashboard to v0.11.6 (#7026) Co-authored-by: ZonaHex <ZonaHex@users.noreply.github.com> Signed-off-by: discord9 <discord9@163.com> * fix: step aggr merge phase not order nor filter (#6998) * fix: not order Signed-off-by: discord9 <discord9@163.com> * test: redacted Signed-off-by: discord9 <discord9@163.com> * feat: fix up state wrapper Signed-off-by: discord9 <discord9@163.com> * df last_value state not as promised! Signed-off-by: discord9 <discord9@163.com> * fix?: could fix better Signed-off-by: discord9 <discord9@163.com> * test: unstable result Signed-off-by: discord9 <discord9@163.com> * fix: work around by fixing state Signed-off-by: discord9 <discord9@163.com> * chore: after rebase fix Signed-off-by: discord9 <discord9@163.com> * chore: finish some todo Signed-off-by: discord9 <discord9@163.com> * chore: per copilot Signed-off-by: discord9 <discord9@163.com> * refactor: not fix but just notify mismatch Signed-off-by: discord9 <discord9@163.com> * chore: warn -> debug state mismatch Signed-off-by: discord9 <discord9@163.com> * chore: refine error msg Signed-off-by: discord9 <discord9@163.com> * test: sqlness add last_value date_bin test Signed-off-by: discord9 <discord9@163.com> * ?: substrait order by decode failure Signed-off-by: discord9 <discord9@163.com> * unit test reproduce that Signed-off-by: discord9 <discord9@163.com> * feat: support state wrapper's order serde in substrait Signed-off-by: discord9 <discord9@163.com> * refactor: stuff Signed-off-by: discord9 <discord9@163.com> * test: standalone/distributed different exec Signed-off-by: discord9 <discord9@163.com> * fmt Signed-off-by: discord9 <discord9@163.com> * chore: per review Signed-off-by: discord9 <discord9@163.com> * refactor: closure Signed-off-by: discord9 <discord9@163.com> * test: first value order by Signed-off-by: discord9 <discord9@163.com> * refactor: per cr Signed-off-by: discord9 <discord9@163.com> * feat: ScanHint last_value last row selector Signed-off-by: discord9 <discord9@163.com> * docs: per cr Signed-off-by: discord9 <discord9@163.com> --------- Signed-off-by: discord9 <discord9@163.com> * chore: bump version to 0.17.2 Signed-off-by: WenyXu <wenymedia@gmail.com> Signed-off-by: discord9 <discord9@163.com> * chore: not warning Signed-off-by: discord9 <discord9@163.com> --------- Signed-off-by: evenyag <realevenyag@gmail.com> Signed-off-by: discord9 <discord9@163.com> Signed-off-by: Shyamnatesan <shyamnatesan21@gmail.com> Signed-off-by: Ruihang Xia <waynestxia@gmail.com> Signed-off-by: shuiyisong <xixing.sys@gmail.com> Signed-off-by: Dennis Zhuang <killme2008@gmail.com> Signed-off-by: WenyXu <wenymedia@gmail.com> Co-authored-by: Yingwen <realevenyag@gmail.com> Co-authored-by: shyam <43544082+Shyamnatesan@users.noreply.github.com> Co-authored-by: Ruihang Xia <waynestxia@gmail.com> Co-authored-by: discord9 <55937128+discord9@users.noreply.github.com> Co-authored-by: shuiyisong <113876041+shuiyisong@users.noreply.github.com> Co-authored-by: dennis zhuang <killme2008@gmail.com> Co-authored-by: ZonaHe <zonahe@qq.com> Co-authored-by: ZonaHex <ZonaHex@users.noreply.github.com> Co-authored-by: discord9 <discord9@163.com>
66 lines
2.2 KiB
SQL
66 lines
2.2 KiB
SQL
-- Migrated from DuckDB test: test/sql/join/left_outer/ pattern tests
|
|
-- Tests common left join patterns
|
|
|
|
CREATE TABLE accounts(acc_id INTEGER, acc_name VARCHAR, balance DOUBLE, ts TIMESTAMP TIME INDEX);
|
|
|
|
CREATE TABLE transactions(txn_id INTEGER, acc_id INTEGER, amount DOUBLE, txn_type VARCHAR, txn_date DATE, ts TIMESTAMP TIME INDEX);
|
|
|
|
INSERT INTO accounts VALUES
|
|
(1, 'Checking', 1500.00, 1000), (2, 'Savings', 5000.00, 2000),
|
|
(3, 'Credit', -250.00, 3000), (4, 'Investment', 10000.00, 4000);
|
|
|
|
INSERT INTO transactions VALUES
|
|
(1, 1, -100.00, 'withdrawal', '2023-01-01', 1000),
|
|
(2, 1, 500.00, 'deposit', '2023-01-02', 2000),
|
|
(3, 2, 1000.00, 'deposit', '2023-01-01', 3000),
|
|
(4, 3, -50.00, 'purchase', '2023-01-03', 4000),
|
|
(5, 1, -25.00, 'fee', '2023-01-04', 5000);
|
|
|
|
-- Left join to find accounts with/without transactions
|
|
SELECT
|
|
a.acc_name, a.balance,
|
|
COUNT(t.txn_id) as transaction_count,
|
|
COALESCE(SUM(t.amount), 0) as total_activity
|
|
FROM accounts a
|
|
LEFT JOIN transactions t ON a.acc_id = t.acc_id
|
|
GROUP BY a.acc_id, a.acc_name, a.balance
|
|
ORDER BY transaction_count DESC, total_activity DESC;
|
|
|
|
-- Left join with date filtering
|
|
SELECT
|
|
a.acc_name,
|
|
COUNT(t.txn_id) as recent_transactions,
|
|
SUM(CASE WHEN t.amount > 0 THEN t.amount ELSE 0 END) as deposits,
|
|
SUM(CASE WHEN t.amount < 0 THEN t.amount ELSE 0 END) as withdrawals
|
|
FROM accounts a
|
|
LEFT JOIN transactions t ON a.acc_id = t.acc_id AND t.txn_date >= '2023-01-02'
|
|
GROUP BY a.acc_id, a.acc_name
|
|
ORDER BY recent_transactions DESC, a.acc_name ASC;
|
|
|
|
-- Left join NULL handling
|
|
SELECT
|
|
a.acc_name,
|
|
a.balance,
|
|
t.txn_id,
|
|
COALESCE(t.amount, 0) as transaction_amount,
|
|
CASE WHEN t.txn_id IS NULL THEN 'No Activity' ELSE 'Has Activity' END as status
|
|
FROM accounts a
|
|
LEFT JOIN transactions t ON a.acc_id = t.acc_id
|
|
ORDER BY a.acc_id, t.txn_date;
|
|
|
|
-- Left join with complex conditions
|
|
SELECT
|
|
a.acc_name,
|
|
COUNT(large_txn.txn_id) as large_transaction_count,
|
|
AVG(large_txn.amount) as avg_large_amount
|
|
FROM accounts a
|
|
LEFT JOIN (
|
|
SELECT * FROM transactions WHERE ABS(amount) > 100.00
|
|
) large_txn ON a.acc_id = large_txn.acc_id
|
|
GROUP BY a.acc_id, a.acc_name
|
|
ORDER BY large_transaction_count DESC, a.acc_name ASC;
|
|
|
|
DROP TABLE accounts;
|
|
|
|
DROP TABLE transactions;
|