dask-sql icon indicating copy to clipboard operation
dask-sql copied to clipboard

use macro to make get_value methods more concise

Open andygrove opened this issue 3 years ago • 2 comments

Following on from https://github.com/dask-contrib/dask-sql/pull/803, this PR demonstrates how we can use a macro to make some of the boilerplate code more concise.

More generally, this PR allows us to discuss whether we want to start using macros in this project.

Pro: Concise code

Con: Rust macros are another language to learn - https://doc.rust-lang.org/book/ch19-06-macros.html

andygrove avatar Sep 28 '22 20:09 andygrove

Macros could be useful for replacing other areas of boilerplate code such as implementing this for each operator:

impl TryFrom<LogicalPlan> for PyProjection {
    type Error = PyErr;

    fn try_from(logical_plan: LogicalPlan) -> Result<Self, Self::Error> {
        match logical_plan {
            LogicalPlan::Projection(projection) => Ok(PyProjection { projection }),
            _ => Err(py_type_err("unexpected plan")),
        }
    }
}

andygrove avatar Sep 28 '22 21:09 andygrove

Codecov Report

Merging #821 (150643a) into main (34b7a4b) will decrease coverage by 0.17%. The diff coverage is n/a.

@@            Coverage Diff             @@
##             main     #821      +/-   ##
==========================================
- Coverage   77.38%   77.21%   -0.18%     
==========================================
  Files          75       75              
  Lines        4219     4217       -2     
  Branches      767      760       -7     
==========================================
- Hits         3265     3256       -9     
- Misses        784      786       +2     
- Partials      170      175       +5     
Impacted Files Coverage Δ
dask_sql/physical/rex/core/literal.py 58.09% <0.00%> (-2.86%) :arrow_down:
dask_sql/_version.py 32.76% <0.00%> (-1.13%) :arrow_down:
dask_sql/physical/rel/custom/predict.py 91.66% <0.00%> (-0.23%) :arrow_down:
dask_sql/utils.py 99.03% <0.00%> (-0.01%) :arrow_down:

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more

codecov-commenter avatar Sep 28 '22 21:09 codecov-commenter