Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions wren-core/core/src/logical_plan/analyze/model_generation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,9 @@ impl ModelGenerationRule {
// The filter should be on on the top of the model plan
// and the model plan should be another subquery alias
if let Some(filter) = rls_filter {
builder =
builder.alias(model_plan.plan_name())?.filter(filter)?;
builder = builder
.alias(quoted(model_plan.plan_name()))?
.filter(filter)?;
// Following the DataFusion planning behavior, we need to
// add a projection behind the filter to ensure the unparsing is correct.
let indices = 0..builder.schema().fields().len();
Expand Down
5 changes: 2 additions & 3 deletions wren-core/core/src/mdl/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,7 @@ impl WindowUDFImpl for ByPassWindowFunction {

#[cfg(test)]
mod test {
use std::slice::from_ref;
use std::sync::Arc;

use crate::mdl::function::{
Expand Down Expand Up @@ -598,9 +599,7 @@ mod test {
DataType::List(Arc::new(Field::new("element", DataType::Int32, false)));
assert_eq!(udf.name, "test");
assert_eq!(
udf.return_type
.to_data_type(std::slice::from_ref(&list_type))
.unwrap(),
udf.return_type.to_data_type(from_ref(&list_type)).unwrap(),
DataType::Int32
);
assert_eq!(
Expand Down
40 changes: 40 additions & 0 deletions wren-core/core/src/mdl/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2523,6 +2523,46 @@ mod test {
Ok(())
}

#[tokio::test]
async fn test_rlac_unicode_model_column_name() -> Result<()> {
let ctx = SessionContext::new();
let manifest = ManifestBuilder::new()
.catalog("wren")
.schema("test")
.model(
ModelBuilder::new("VTU藝人")
.table_reference("artist")
.column(ColumnBuilder::new("名字", "string").build())
.column(ColumnBuilder::new("組別", "string").build())
.column(ColumnBuilder::new("訂閱數", "int").build())
.add_row_level_access_control(
"rule",
vec![SessionProperty::new_required("預定組別A")],
"\"組別\" = @預定組別A",
)
.build(),
)
.build();
let headers = Arc::new(build_headers(&[(
"預定組別A".to_string(),
Some("'JP'".to_string()),
)]));

let analyzed_mdl = Arc::new(AnalyzedWrenMDL::analyze(
manifest,
Arc::clone(&headers),
Mode::Unparse,
)?);

let sql = r#"SELECT "名字", "組別", "訂閱數" FROM "VTU藝人""#;
assert_snapshot!(
transform_sql_with_ctx(&ctx, Arc::clone(&analyzed_mdl), &[], headers, sql)
.await?,
@r#"SELECT "VTU藝人"."名字", "VTU藝人"."組別", "VTU藝人"."訂閱數" FROM (SELECT "VTU藝人"."名字", "VTU藝人"."組別", "VTU藝人"."訂閱數" FROM (SELECT "VTU藝人"."名字", "VTU藝人"."組別", "VTU藝人"."訂閱數" FROM (SELECT __source."名字" AS "名字", __source."組別" AS "組別", __source."訂閱數" AS "訂閱數" FROM artist AS __source) AS "VTU藝人") AS "VTU藝人" WHERE "VTU藝人"."組別" = 'JP') AS "VTU藝人""#
);
Ok(())
}

#[tokio::test]
async fn test_clac_with_required_properties() -> Result<()> {
let ctx = SessionContext::new();
Expand Down
Loading