package sdf:df;
interface types {
use sdf:arrow/types.{ dtype, dvalue as lit};
type index = u16;
type expressions = list<expr>;
// list of expr node based on https://datafusion.apache.org/user-guide/expressions.html
variant operation {
filter(expressions)
}
// content of the each AST
variant expr {
binary(binary-exp),
col(column),
lit(lit),
}
record binary-exp {
operator: operator,
left: index,
right: index
}
variant operator {
plus,
minus,
lt-eq,
eq,
gt
}
record column {
name: string
}
record sort-options {
descending: list<bool>,
maintain-order: bool,
}
record column-names {
names: list<string>
}
record column-schema {
name: string,
index: u8,
schema: dtype
}
}
interface lazy {
use types.{ index, expressions, binary-exp, operator, column, operation, lit, sort-options, column-names, dtype, column-schema };
// presents data frame as resource
resource df-value {
// find: static func(name: string) -> option<df-value>;
run: func(ops: operation) -> result<df-value, string>;
select: func(columns: column-names) -> result<df-value,string>;
sort: func(columns: column-names, options: sort-options) -> result<df-value,string>;
shape: func() -> tuple<u64,u64>;
schema: func(columns: column-names) -> result<list<column-schema>,string>;
rows: func() -> result<row-value,string>;
sql: func(sql: string) -> result<df-value,string>;
head: func(rows: u64) -> result<df-value,string>;
name: func() -> string;
}
resource row-value {
end: func() -> bool;
next: func() -> bool;
index: func() -> s64;
skip: func(row: s64) -> bool;
value: func(col: u8) -> option<lit>;
}
}
world arrow-world {
import lazy;
}