From 385bfa7467bece078b0e401168f3b331e261c54d Mon Sep 17 00:00:00 2001 From: YANGDB Date: Wed, 13 Nov 2024 16:19:47 -0700 Subject: [PATCH] update more sample test tables and commands Signed-off-by: YANGDB --- .../local-spark-ppl-test-instruction.md | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/docs/ppl-lang/local-spark-ppl-test-instruction.md b/docs/ppl-lang/local-spark-ppl-test-instruction.md index fdb2b2301..917ccb010 100644 --- a/docs/ppl-lang/local-spark-ppl-test-instruction.md +++ b/docs/ppl-lang/local-spark-ppl-test-instruction.md @@ -126,6 +126,18 @@ age email host Time taken: 1.555 seconds, Fetched 3 row(s) ``` +### Test `grok` | `top` commands combination +```sql +source=emails| grok email '.+@%{HOSTNAME:host}' | fields email, host | top 3 host; + +count_host host +2 examples.com +1 demonstration.com +1 test.org + +Time taken: 1.274 seconds, Fetched 3 row(s) +``` + ### Test `fieldsummary` command ```sql @@ -260,5 +272,34 @@ int_col multi_valueB value name Time taken: 0.111 seconds, Fetched 8 row(s) ``` +## ip table + +```sql +CREATE TABLE ipTable ( id INT,ipAddress STRING,isV6 BOOLEAN, isValid BOOLEAN) using csv OPTIONS (header 'false',delimiter '\\t'); +INSERT INTO ipTable values (1, '127.0.0.1', false, true), (2, '192.168.1.0', false, true),(3, '192.168.1.1', false, true),(4, '192.168.2.1', false, true), (5, '192.168.2.', false, false),(6, '2001:db8::ff00:12:3455', true, true),(7, '2001:db8::ff00:12:3456', true, true),(8, '2001:db8::ff00:13:3457', true, true), (9, '2001:db8::ff00:12:', true, false); +``` + +### Test `cidr` command + +```sql +source=ipTable | where isV6 = false and isValid = true and cidrmatch(ipAddress, '192.168.1.0/24'); + +id ipAddress isV6 isValid +2 192.168.1.0 false true +3 192.168.1.1 false true + +Time taken: 0.317 seconds, Fetched 2 row(s) +``` + +```sql +source=ipTable | where isV6 = true and isValid = true and cidrmatch(ipAddress, '2001:db8::/32'); + +id ipAddress isV6 isValid +6 2001:db8::ff00:12:3455 true true +8 2001:db8::ff00:13:3457 true true +7 2001:db8::ff00:12:3456 true true + +Time taken: 0.09 seconds, Fetched 3 row(s) +``` --- \ No newline at end of file