Skip to content

Commit 4163ea7

Browse files
committed
init commit
1 parent b4b0406 commit 4163ea7

2 files changed

Lines changed: 50 additions & 3 deletions

File tree

README.md

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,50 @@ and [Arrow DataFusion](https://github.com/apache/arrow-datafusion).
66
### Why Dataframe
77

88
Dataframe removes the complexity of handling `SQL parsing`, `SQL rewriting`, `Binding`, `SQL Query Planner` etc. Once
9-
the dataframe is mature, we can easily integrate it with an SQL engine.
9+
the dataframe is mature, we can easily integrate it with an SQL engine.
10+
11+
12+
### Example
13+
14+
```go
15+
package main
16+
17+
import (
18+
"fmt"
19+
"tiny_dataframe/pkg/a_engine"
20+
logicalplan "tiny_dataframe/pkg/c_logical_plan"
21+
)
22+
23+
func main() {
24+
ctx := engine.NewContext()
25+
df, _ := ctx.Parquet("../../test/data/c1_c2_int64.parquet", nil)
26+
27+
df = df.
28+
Project(
29+
logicalplan.Column{Name: "c1"},
30+
logicalplan.Column{Name: "c2"},
31+
).
32+
Filter(logicalplan.Eq(
33+
logicalplan.Column{Name: "c1"},
34+
logicalplan.LiteralInt64{Val: 100},
35+
))
36+
37+
logicalPlan, _ := df.LogicalPlan()
38+
fmt.Println(logicalplan.PrettyPrint(logicalPlan, 0))
39+
/*
40+
Filter: #c1 = 100
41+
Projection: #c1, #c2
42+
Input: ../../test/data/c1_c2_int64.parquet; projExpr=None
43+
*/
44+
45+
_ = df.Show()
46+
/*
47+
+-----+-----+
48+
| C1 | C2 |
49+
+-----+-----+
50+
| 100 | 101 |
51+
+-----+-----+
52+
*/
53+
}
54+
55+
```
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
package engine
1+
package simple
22

33
import (
44
"fmt"
55
"testing"
6+
"tiny_dataframe/pkg/a_engine"
67
logicalplan "tiny_dataframe/pkg/c_logical_plan"
78
)
89

910
func TestParquetFile(t *testing.T) {
10-
ctx := NewContext()
11+
ctx := engine.NewContext()
1112
df, err := ctx.Parquet("../../test/data/c1_c2_int64.parquet", nil)
1213
if err != nil {
1314
t.Error(err)

0 commit comments

Comments
 (0)