From 2037db7f7b15385175336eb9c01a85f672e4ecac Mon Sep 17 00:00:00 2001
From: Raphael Taylor-Davies <1781103+tustvold@users.noreply.github.com>
Date: Fri, 6 Jan 2023 07:36:29 +0000
Subject: [PATCH] refactor: decouple influxql from SchemaProvider (#6507)
* refactor: decouple influxql from SchemaProvider
* refactor: reorder arguments
* refactor: use QueryNamespaceMeta
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
---
.../src/plan/influxql/expr_type_evaluator.rs | 101 +++++++++-----
iox_query/src/plan/influxql/field_mapper.rs | 123 +++++++-----------
iox_query/src/plan/influxql/rewriter.rs | 104 +++++++--------
iox_query/src/plan/influxql/test_utils.rs | 94 +++----------
4 files changed, 185 insertions(+), 237 deletions(-)
diff --git a/iox_query/src/plan/influxql/expr_type_evaluator.rs b/iox_query/src/plan/influxql/expr_type_evaluator.rs
index ff05735f45..f696940ae2 100644
--- a/iox_query/src/plan/influxql/expr_type_evaluator.rs
+++ b/iox_query/src/plan/influxql/expr_type_evaluator.rs
@@ -1,31 +1,32 @@
use crate::plan::influxql::field::field_by_name;
-use crate::plan::influxql::field_mapper::FieldMapper;
+use crate::plan::influxql::field_mapper::map_type;
use datafusion::common::{DataFusionError, Result};
use influxdb_influxql_parser::common::{MeasurementName, QualifiedMeasurementName};
use influxdb_influxql_parser::expression::{Expr, UnaryOperator, VarRefDataType};
use influxdb_influxql_parser::literal::Literal;
use influxdb_influxql_parser::select::{Dimension, FromMeasurementClause, MeasurementSelection};
use itertools::Itertools;
+use predicate::rpc_predicate::QueryNamespaceMeta;
/// Evaluate the type of the specified expression.
///
/// Derived from [Go implementation](https://github.com/influxdata/influxql/blob/1ba470371ec093d57a726b143fe6ccbacf1b452b/ast.go#L4796-L4797).
pub(crate) fn evaluate_type(
+ namespace: &dyn QueryNamespaceMeta,
expr: &Expr,
from: &FromMeasurementClause,
- fm: &dyn FieldMapper,
) -> Result