()
| 6152 | |
| 6153 | #[tokio::test] |
| 6154 | async fn test_alias() -> Result<()> { |
| 6155 | let df = create_test_table("test") |
| 6156 | .await? |
| 6157 | .select(vec![col("a"), col("test.b"), lit(1).alias("one")])? |
| 6158 | .alias("table_alias")?; |
| 6159 | // All output column qualifiers are changed to "table_alias" |
| 6160 | df.schema().columns().iter().for_each(|c| { |
| 6161 | assert_eq!(c.relation, Some("table_alias".into())); |
| 6162 | }); |
| 6163 | |
| 6164 | let plan = df |
| 6165 | .clone() |
| 6166 | .into_unoptimized_plan() |
| 6167 | .display_indent_schema() |
| 6168 | .to_string(); |
| 6169 | assert_snapshot!(plan, @r" |
| 6170 | SubqueryAlias: table_alias [a:Utf8, b:Int32, one:Int32] |
| 6171 | Projection: test.a, test.b, Int32(1) AS one [a:Utf8, b:Int32, one:Int32] |
| 6172 | TableScan: test [a:Utf8, b:Int32] |
| 6173 | "); |
| 6174 | |
| 6175 | // Select over the aliased DataFrame |
| 6176 | let df = df.select(vec![ |
| 6177 | col("table_alias.a"), |
| 6178 | col("b") + col("table_alias.one"), |
| 6179 | ])?; |
| 6180 | assert_snapshot!( |
| 6181 | batches_to_sort_string(&df.collect().await.unwrap()), |
| 6182 | @r" |
| 6183 | +-----------+---------------------------------+ |
| 6184 | | a | table_alias.b + table_alias.one | |
| 6185 | +-----------+---------------------------------+ |
| 6186 | | 123AbcDef | 101 | |
| 6187 | | CBAdef | 11 | |
| 6188 | | abc123 | 11 | |
| 6189 | | abcDEF | 2 | |
| 6190 | +-----------+---------------------------------+ |
| 6191 | " |
| 6192 | ); |
| 6193 | Ok(()) |
| 6194 | } |
| 6195 | |
| 6196 | #[tokio::test] |
| 6197 | async fn test_alias_with_metadata() -> Result<()> { |
nothing calls this directly
no test coverage detected
searching dependent graphs…