Skip to content

Commit

Permalink
Merge branch 'main' into feature/hidden-column
Browse files Browse the repository at this point in the history
  • Loading branch information
goldmedal committed Oct 30, 2024
2 parents ff24b65 + 3ed5e2a commit 1768895
Show file tree
Hide file tree
Showing 10 changed files with 309 additions and 324 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/build-dev-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ jobs:
build-args: |
WREN_VERSION=${{ steps.prepare.outputs.WREN_VERSION }}
push: true
cache-from: type=gha
cache-to: type=gha,mode=max
build-ibis-image:
runs-on: ubuntu-latest
steps:
Expand Down Expand Up @@ -89,3 +91,5 @@ jobs:
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
cache-from: type=gha
cache-to: type=gha,mode=max
4 changes: 4 additions & 0 deletions .github/workflows/build-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ jobs:
build-args: |
WREN_VERSION=${{ steps.prepare.outputs.WREN_VERSION }}
push: true
cache-from: type=gha
cache-to: type=gha,mode=max
build-ibis-image:
needs: prepare-tag
runs-on: ubuntu-latest
Expand Down Expand Up @@ -101,3 +103,5 @@ jobs:
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
cache-from: type=gha
cache-to: type=gha,mode=max
4 changes: 4 additions & 0 deletions .github/workflows/stable-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ jobs:
build-args: |
WREN_VERSION=${{ steps.prepare.outputs.WREN_VERSION }}
push: true
cache-from: type=gha
cache-to: type=gha,mode=max
stable-release-ibis:
needs: prepare-version
runs-on: ubuntu-latest
Expand Down Expand Up @@ -148,3 +150,5 @@ jobs:
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
cache-from: type=gha
cache-to: type=gha,mode=max
533 changes: 274 additions & 259 deletions ibis-server/poetry.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion ibis-server/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ pandas = "2.2.3"
sqlglot = ">=23.4,<25.21"
loguru = "0.7.2"
asgi-correlation-id = "4.3.4"
gql = { extras = ["aiohttp"], version = "3.5.0" }

[tool.poetry.group.dev.dependencies]
pytest = "8.3.3"
Expand All @@ -42,7 +43,6 @@ pre-commit = "4.0.1"
ruff = "0.7.1"
trino = ">=0.321,<1"
psycopg2 = ">=2.8.4,<3"
gql = { extras = ["aiohttp"], version = "3.5.0" }
clickhouse-connect = "0.8.5"

[tool.pytest.ini_options]
Expand Down
2 changes: 1 addition & 1 deletion ibis-server/tests/routers/v3/connector/test_postgres.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ def test_query_with_invalid_manifest_str(postgres: PostgresContainer):
},
)
assert response.status_code == 422
assert response.text == "Invalid padding"
assert response.text == "Base64 decode error: Invalid padding"

def test_query_without_manifest(postgres: PostgresContainer):
connection_info = _to_connection_info(postgres)
Expand Down
8 changes: 4 additions & 4 deletions wren-core-py/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ impl PySessionContext {
mdl_base64: Option<&str>,
remote_functions_path: Option<&str>,
) -> PyResult<Self> {
let remote_functions =
Self::read_remote_function_list(remote_functions_path).unwrap();
let remote_functions = Self::read_remote_function_list(remote_functions_path)
.map_err(CoreError::from)?;
let remote_functions: Vec<RemoteFunction> = remote_functions
.into_iter()
.map(|f| f.into())
Expand Down Expand Up @@ -101,7 +101,7 @@ impl PySessionContext {

let analyzed_mdl = Arc::new(analyzed_mdl);

let runtime = tokio::runtime::Runtime::new().unwrap();
let runtime = tokio::runtime::Runtime::new().map_err(CoreError::from)?;
let ctx = runtime
.block_on(create_ctx_with_mdl(&ctx, Arc::clone(&analyzed_mdl), false))
.map_err(CoreError::from)?;
Expand Down Expand Up @@ -229,7 +229,7 @@ impl PySessionContext {
);
if let Some(path) = path {
Ok(csv::Reader::from_path(path)
.unwrap()
.map_err(CoreError::from)?
.into_deserialize::<PyRemoteFunction>()
.filter_map(Result::ok)
.collect::<Vec<_>>())
Expand Down
22 changes: 17 additions & 5 deletions wren-core-py/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,30 +26,42 @@ impl From<CoreError> for PyErr {

impl From<PyErr> for CoreError {
fn from(err: PyErr) -> Self {
CoreError::new(&err.to_string())
CoreError::new(&format!("PyError: {}", &err))
}
}

impl From<DecodeError> for CoreError {
fn from(err: DecodeError) -> Self {
CoreError::new(&err.to_string())
CoreError::new(&format!("Base64 decode error: {}", err))
}
}

impl From<FromUtf8Error> for CoreError {
fn from(err: FromUtf8Error) -> Self {
CoreError::new(&err.to_string())
CoreError::new(&format!("FromUtf8Error: {}", err))
}
}

impl From<serde_json::Error> for CoreError {
fn from(err: serde_json::Error) -> Self {
CoreError::new(&err.to_string())
CoreError::new(&format!("Serde JSON error: {}", err))
}
}

impl From<wren_core::DataFusionError> for CoreError {
fn from(err: wren_core::DataFusionError) -> Self {
CoreError::new(&err.to_string())
CoreError::new(&format!("DataFusion error: {}", err))
}
}

impl From<csv::Error> for CoreError {
fn from(err: csv::Error) -> Self {
CoreError::new(&format!("CSV error: {}", err))
}
}

impl From<std::io::Error> for CoreError {
fn from(err: std::io::Error) -> Self {
CoreError::new(&format!("IO error: {}", err))
}
}
44 changes: 0 additions & 44 deletions wren-core/core/src/mdl/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
use crate::mdl::manifest::{
Column, JoinType, Manifest, Metric, Model, Relationship, TimeGrain, TimeUnit, View,
};
use std::collections::BTreeMap;
use std::sync::Arc;

/// A builder for creating a Manifest
Expand Down Expand Up @@ -82,7 +81,6 @@ impl ModelBuilder {
primary_key: None,
cached: false,
refresh_time: None,
properties: BTreeMap::default(),
},
}
}
Expand Down Expand Up @@ -122,13 +120,6 @@ impl ModelBuilder {
self
}

pub fn property(mut self, key: &str, value: &str) -> Self {
self.model
.properties
.insert(key.to_string(), value.to_string());
self
}

pub fn build(self) -> Arc<Model> {
Arc::new(self.model)
}
Expand All @@ -149,7 +140,6 @@ impl ColumnBuilder {
is_hidden: false,
not_null: false,
expression: None,
properties: BTreeMap::default(),
},
}
}
Expand Down Expand Up @@ -211,7 +201,6 @@ impl RelationshipBuilder {
models: vec![],
join_type: JoinType::OneToOne,
condition: "".to_string(),
properties: BTreeMap::default(),
},
}
}
Expand All @@ -231,13 +220,6 @@ impl RelationshipBuilder {
self
}

pub fn property(mut self, key: &str, value: &str) -> Self {
self.relationship
.properties
.insert(key.to_string(), value.to_string());
self
}

pub fn build(self) -> Arc<Relationship> {
Arc::new(self.relationship)
}
Expand All @@ -258,7 +240,6 @@ impl MetricBuilder {
time_grain: vec![],
cached: false,
refresh_time: None,
properties: BTreeMap::default(),
},
}
}
Expand Down Expand Up @@ -288,13 +269,6 @@ impl MetricBuilder {
self
}

pub fn property(mut self, key: &str, value: &str) -> Self {
self.metric
.properties
.insert(key.to_string(), value.to_string());
self
}

pub fn build(self) -> Arc<Metric> {
Arc::new(self.metric)
}
Expand Down Expand Up @@ -340,7 +314,6 @@ impl ViewBuilder {
view: View {
name: name.to_string(),
statement: "".to_string(),
properties: BTreeMap::default(),
},
}
}
Expand All @@ -350,13 +323,6 @@ impl ViewBuilder {
self
}

pub fn property(mut self, key: &str, value: &str) -> Self {
self.view
.properties
.insert(key.to_string(), value.to_string());
self
}

pub fn build(self) -> Arc<View> {
Arc::new(self.view)
}
Expand All @@ -381,7 +347,6 @@ mod test {
.not_null(true)
.hidden(true)
.expression("test")
.property("key", "value")
.build();

let json_str = serde_json::to_string(&expected).unwrap();
Expand Down Expand Up @@ -437,7 +402,6 @@ mod test {
.primary_key("id")
.cached(true)
.refresh_time("1h")
.property("key", "value")
.build();

let json_str = serde_json::to_string(&model).unwrap();
Expand All @@ -452,7 +416,6 @@ mod test {
.primary_key("id")
.cached(true)
.refresh_time("1h")
.property("key", "value")
.build();

let json_str = serde_json::to_string(&model).unwrap();
Expand All @@ -477,7 +440,6 @@ mod test {
.model("testB")
.join_type(JoinType::OneToMany)
.condition("test")
.property("key", "value")
.build();

let json_str = serde_json::to_string(&expected).unwrap();
Expand Down Expand Up @@ -530,7 +492,6 @@ mod test {
)
.cached(true)
.refresh_time("1h")
.property("key", "value")
.build();

let json_str = serde_json::to_string(&model).unwrap();
Expand All @@ -542,7 +503,6 @@ mod test {
fn test_view_roundtrip() {
let expected = ViewBuilder::new("test")
.statement("SELECT * FROM test")
.property("key", "value")
.build();

let json_str = serde_json::to_string(&expected).unwrap();
Expand All @@ -560,15 +520,13 @@ mod test {
.primary_key("id")
.cached(true)
.refresh_time("1h")
.property("key", "value")
.build();

let relationship = RelationshipBuilder::new("test")
.model("testA")
.model("testB")
.join_type(JoinType::OneToMany)
.condition("test")
.property("key", "value")
.build();

let metric = MetricBuilder::new("test")
Expand All @@ -582,12 +540,10 @@ mod test {
)
.cached(true)
.refresh_time("1h")
.property("key", "value")
.build();

let view = ViewBuilder::new("test")
.statement("SELECT * FROM test")
.property("key", "value")
.build();

let expected = crate::mdl::builder::ManifestBuilder::new()
Expand Down
10 changes: 0 additions & 10 deletions wren-core/core/src/mdl/manifest.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use std::collections::BTreeMap;
use std::fmt::Display;
use std::sync::Arc;

Expand Down Expand Up @@ -39,8 +38,6 @@ pub struct Model {
pub cached: bool,
#[serde(default)]
pub refresh_time: Option<String>,
#[serde(default)]
pub properties: BTreeMap<String, String>,
}

impl Model {
Expand Down Expand Up @@ -172,8 +169,6 @@ pub struct Column {
pub expression: Option<String>,
#[serde(default, with = "bool_from_int")]
pub is_hidden: bool,
#[serde(default)]
pub properties: BTreeMap<String, String>,
}

#[derive(Serialize, Deserialize, Debug, Hash, PartialEq, Eq)]
Expand All @@ -183,8 +178,6 @@ pub struct Relationship {
pub models: Vec<String>,
pub join_type: JoinType,
pub condition: String,
#[serde(default)]
pub properties: BTreeMap<String, String>,
}

#[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Hash, Clone, Copy)]
Expand Down Expand Up @@ -228,7 +221,6 @@ pub struct Metric {
#[serde(default, with = "bool_from_int")]
pub cached: bool,
pub refresh_time: Option<String>,
pub properties: BTreeMap<String, String>,
}

impl Metric {
Expand Down Expand Up @@ -259,8 +251,6 @@ pub enum TimeUnit {
pub struct View {
pub name: String,
pub statement: String,
#[serde(default)]
pub properties: BTreeMap<String, String>,
}

impl View {
Expand Down

0 comments on commit 1768895

Please sign in to comment.