cfahlgren1 HF staff commited on
Commit
e6091f8
1 Parent(s): 318fad3

add duplicate checker

Browse files
src/snippets/checking-duplicate-dataset.md ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ id: "duckdb-check-duplicate-rows"
3
+ title: "Check Duplicate Rows"
4
+ slug: "duckdb-check-duplicate-rows-query"
5
+ description: "Count the number of duplicate rows in a table using DuckDB."
6
+ code: |
7
+ -- Count duplicate rows in the 'train' table
8
+ SELECT COUNT(*) - COUNT(DISTINCT columns(*))
9
+ FROM train;
10
+ ---
11
+
12
+ # DuckDB Check Duplicate Rows Query
13
+
14
+ This snippet demonstrates how to count the number of duplicate rows in a DuckDB table using a SQL query.
15
+
16
+ ```sql
17
+ -- Count duplicate rows in the 'train' table
18
+ SELECT COUNT(*) - COUNT(DISTINCT columns(*))
19
+ FROM train;
20
+ ```
21
+
22
+ This query works by:
23
+ 1. Counting all rows using `COUNT(*)`
24
+ 2. Subtracting the count of distinct rows using `COUNT(DISTINCT *)`
25
+ 3. The result is the number of duplicate rows
26
+
27
+ You can replace 'train' with the name of your specific table to check for duplicates in other tables.
28
+
29
+ Note: This query can be computationally expensive for large tables, as it needs to check all columns for uniqueness.
src/snippets/unnest.md ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ id: "duckdb-table-info"
3
+ title: "Table Info"
4
+ slug: "duckdb-table-info-query"
5
+ description: "Get detailed information about a table's structure"
6
+ code: |
7
+ with nested as
8
+ (
9
+ select unnest(reasoning_chains) as reasoning_chains
10
+ from train limit 100
11
+ )
12
+
13
+ select reasoning_chains.* from nested;
14
+ ---
15
+
16
+ # DuckDB Table Info Query
17
+
18
+ This snippet demonstrates how to use the `PRAGMA table_info` function in DuckDB to get detailedinformation about a specific table's structure.
19
+
20
+ Try out this query [here](https://huggingface.co/datasets/NousResearch/hermes-function-calling-v1?sql_console=true&sql=pragma+table_info%28%27func_calling_singleturn%27%29)
21
+
22
+ ```sql
23
+ -- Returns detailed information about a table's structure
24
+ -- Use this to get the column names, types, and other details
25
+ PRAGMA table_info('table_name');
26
+ ```
27
+
28
+ # Example Output
29
+
30
+ | cid | name | type | notnull | dflt_value | pk |
31
+ |-----|---------------|------------------------------------------|---------|------------|-------|
32
+ | 0 | id | VARCHAR | false | null | false |
33
+ | 1 | conversations | STRUCT("from" VARCHAR, "value" VARCHAR)[] | false | null | false |
34
+ | 2 | category | VARCHAR | false | null | false |
35
+ | 3 | subcategory | VARCHAR | false | null | false |
36
+ | 4 | task | VARCHAR | false | null | false |
37
+
38
+ You can read more about this [here](https://duckdb.org/docs/sql/query_syntax/unnest.html).
39
+
40
+ # Example Usage
41
+
42
+ <iframe
43
+ src="https://huggingface.co/datasets/SkunkworksAI/reasoning-0.01/embed/viewer/default/train?sql_console=true&sql=with+nested+as+%0A++%28%0A++select+unnest%28reasoning_chains%29+as+reasoning_chains%0A++from+train+limit+100%0A%29%0A%0Aselect+reasoning_chains.*+from+nested%3B"
44
+ frameborder="0"
45
+ width="100%"
46
+ height="560px"
47
+ ></iframe>