Skip to content
This repository has been archived by the owner on Jun 6, 2024. It is now read-only.

Commit

Permalink
start creating mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
connortsui20 committed Feb 13, 2024
1 parent 992a38b commit f0bd8ec
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 4 deletions.
11 changes: 9 additions & 2 deletions eggstrain/src/execution/substrait/deserialize.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
use std::fs;
use substrait::proto::Plan;
use substrait::proto::{Plan, ReadRel};

pub fn read_str(path: &str) -> String {
fs::read_to_string(path).unwrap_or_else(|_| panic!("Unable to read file {}", path))
}

pub fn get_json(path: &str) -> Plan {
pub fn get_plan(path: &str) -> Plan {
let plan = serde_json::from_str::<Plan>(&read_str(path))
.unwrap_or_else(|_| panic!("Could not parse json {:?} into Plan", path));
println!("{}", serde_json::to_string_pretty(&plan).unwrap());
plan
}

pub fn get_read(path: &str) -> ReadRel {
let read = serde_json::from_str::<ReadRel>(&read_str(path))
.unwrap_or_else(|_| panic!("Could not parse json {:?} into Plan", path));
println!("{}", serde_json::to_string_pretty(&read).unwrap());
read
}
1 change: 1 addition & 0 deletions eggstrain/src/execution/substrait/mod.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
pub mod deserialize;
pub mod example;
pub mod substrait_arrow;
20 changes: 20 additions & 0 deletions eggstrain/src/execution/substrait/substrait_arrow.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
use arrow::datatypes::{DataType, Schema};
use std::sync::Arc;
use substrait::proto::{Type, NamedStruct};

/// https://docs.rs/substrait/latest/substrait/proto/struct.NamedStruct.html
/// https://docs.rs/substrait/latest/substrait/proto/type/struct.Struct.html
pub fn schema_translate(substrait_schema: NamedStruct) -> Arc<Schema> {
for (i, name) in substrait_schema.names.iter().enumerate() {
todo!()
}

todo!()
}

/// https://docs.rs/substrait/latest/substrait/proto/struct.Type.html
/// https://docs.rs/arrow/latest/arrow/datatypes/enum.DataType.html
pub fn type_translate(typ: Type) -> DataType {
todo!()
}

5 changes: 3 additions & 2 deletions eggstrain/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ pub mod execution;
pub mod scheduler_client;
pub mod storage_client;

use execution::substrait::deserialize::get_json;
use execution::substrait::deserialize::*;

#[tokio::main]
async fn main() {
println!("Hello, world!");
get_json("../substrait/substrait_plan_example.json");
// get_plan("../substrait/substrait_plan_example.json");
// get_json("../substrait/basic_query.json");
get_read("../substrait/read_rel_example.json");
}

0 comments on commit f0bd8ec

Please sign in to comment.