Files
greptimedb/tests/cases/standalone/common/sample/basic_sample.sql
dennis zhuang d8563ba56d feat: adds regex_extract function and more type tests (#7107)
* feat: adds format, regex_extract function and more type tests

Signed-off-by: Dennis Zhuang <killme2008@gmail.com>

* fix: forgot functions

Signed-off-by: Dennis Zhuang <killme2008@gmail.com>

* chore: forgot null type

Signed-off-by: Dennis Zhuang <killme2008@gmail.com>

* test: forgot date type

Signed-off-by: Dennis Zhuang <killme2008@gmail.com>

* feat: remove format function

Signed-off-by: Dennis Zhuang <killme2008@gmail.com>

* test: update results after upgrading datafusion

Signed-off-by: Dennis Zhuang <killme2008@gmail.com>

---------

Signed-off-by: Dennis Zhuang <killme2008@gmail.com>
2025-10-25 08:41:49 +00:00

35 lines
1.2 KiB
SQL

-- Migrated from DuckDB test: test/sql/sample/same_seed_same_sample.test
-- FIXME: the results are wrong in this test, waits for https://github.com/apache/datafusion/pull/16325
-- Test basic SAMPLE functionality
-- Create test table
CREATE TABLE test(x INTEGER, ts TIMESTAMP TIME INDEX);
-- Insert test data
INSERT INTO test SELECT number, number * 1000 FROM numbers limit 10000;
-- Test TABLESAMPLE with percentage
SELECT COUNT(*) > 0 FROM test TABLESAMPLE (10 PERCENT);
-- Test TABLESAMPLE with row count
SELECT COUNT(*) FROM test TABLESAMPLE (100 ROWS);
-- Test TABLESAMPLE SYSTEM
SELECT COUNT(*) > 0 FROM test TABLESAMPLE SYSTEM (25 PERCENT);
-- Test TABLESAMPLE BERNOULLI
SELECT COUNT(*) > 0 FROM test TABLESAMPLE BERNOULLI (25 PERCENT);
-- Test with REPEATABLE for consistent results
SELECT COUNT(*) AS cnt1 FROM test TABLESAMPLE SYSTEM (10 PERCENT) REPEATABLE (42);
SELECT COUNT(*) AS cnt2 FROM test TABLESAMPLE SYSTEM (10 PERCENT) REPEATABLE (42);
-- Test sampling with WHERE clause
SELECT COUNT(*) FROM test TABLESAMPLE (10 PERCENT) WHERE x > 5000;
-- Test sampling with ORDER BY
SELECT x FROM test TABLESAMPLE (5 ROWS) ORDER BY x LIMIT 5;
-- cleanup
DROP TABLE test;