MCPcopy Create free account
hub / github.com/apache/datafusion / project_orderings2

Function project_orderings2

datafusion/physical-expr/src/projection.rs:1826–2009  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1824
1825 #[test]
1826 fn project_orderings2() -> Result<()> {
1827 let schema = Arc::new(Schema::new(vec![
1828 Field::new("a", DataType::Int32, true),
1829 Field::new("b", DataType::Int32, true),
1830 Field::new("c", DataType::Int32, true),
1831 Field::new("d", DataType::Int32, true),
1832 Field::new("ts", DataType::Timestamp(TimeUnit::Nanosecond, None), true),
1833 ]));
1834 let col_a = &col("a", &schema)?;
1835 let col_b = &col("b", &schema)?;
1836 let col_c = &col("c", &schema)?;
1837 let col_ts = &col("ts", &schema)?;
1838 let a_plus_b = Arc::new(BinaryExpr::new(
1839 Arc::clone(col_a),
1840 Operator::Plus,
1841 Arc::clone(col_b),
1842 )) as Arc<dyn PhysicalExpr>;
1843
1844 let test_fun = Arc::new(ScalarUDF::new_from_impl(TestScalarUDF::new()));
1845
1846 let round_c = Arc::new(ScalarFunctionExpr::try_new(
1847 test_fun,
1848 vec![Arc::clone(col_c)],
1849 &schema,
1850 Arc::new(ConfigOptions::default()),
1851 )?) as PhysicalExprRef;
1852
1853 let option_asc = SortOptions {
1854 descending: false,
1855 nulls_first: false,
1856 };
1857
1858 let proj_exprs = vec![
1859 (col_b, "b_new".to_string()),
1860 (col_a, "a_new".to_string()),
1861 (col_c, "c_new".to_string()),
1862 (&round_c, "round_c_res".to_string()),
1863 ];
1864 let proj_exprs = proj_exprs
1865 .into_iter()
1866 .map(|(expr, name)| (Arc::clone(expr), name));
1867 let projection_mapping = ProjectionMapping::try_new(proj_exprs, &schema)?;
1868 let output_schema = output_schema(&projection_mapping, &schema)?;
1869
1870 let col_a_new = &col("a_new", &output_schema)?;
1871 let col_b_new = &col("b_new", &output_schema)?;
1872 let col_c_new = &col("c_new", &output_schema)?;
1873 let col_round_c_res = &col("round_c_res", &output_schema)?;
1874 let a_new_plus_b_new = Arc::new(BinaryExpr::new(
1875 Arc::clone(col_a_new),
1876 Operator::Plus,
1877 Arc::clone(col_b_new),
1878 )) as Arc<dyn PhysicalExpr>;
1879
1880 let test_cases = [
1881 // ---------- TEST CASE 1 ------------
1882 (
1883 // orderings

Callers

nothing calls this directly

Calls 10

newFunction · 0.85
convert_to_orderingsFunction · 0.85
oeq_classMethod · 0.80
output_schemaFunction · 0.70
colFunction · 0.50
mapMethod · 0.45
into_iterMethod · 0.45
iterMethod · 0.45
add_orderingsMethod · 0.45
projectMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…