fn date_function(f: &ast::Function, ctx: &QueryContext) -> CompilationResult<CompiledExpression> {
    let date_expr = match f.args.as_slice() {
        [ast::FunctionArg::Unnamed(date_expr)] => date_expr,
        _ => {
            return Err(CompilationError::User(format!(
                "Unsupported signature for DATE function: {:?}",
                f
            )));
        }
    };

    let compiled = compile_expression(&date_expr, &ctx)?;
    match compiled {
        date @ CompiledExpression::DateLiteral(_) => Ok(date),
        CompiledExpression::StringLiteral(ref input) => {
            let parsed_date = Utc
                .datetime_from_str(input.as_str(), "%Y-%m-%d %H:%M:%S.%f")
                .map_err(|e| {
                    CompilationError::User(format!(
                        "Unable to parse {}, err: {}",
                        input,
                        e.to_string(),
                    ))
                })?;

            Ok(CompiledExpression::DateLiteral(parsed_date))
        }
        _ => {
            return Err(CompilationError::User(format!(
                "Wrong type of argument (date), must be DateLiteral, actual: {:?}",
                f
            )))
        }
    }
}
// DATE(expr)
// Extracts the date part of the date or datetime expression expr.
DATE(expr)
Extracts the date part of the date or datetime expression expr.
DATE ( expr ) Extracts the date part of the date or datetime expression expr .
fn date_function(f: &ast::Function, ctx: &QueryContext) -> CompilationResult<CompiledExpression> {
    let date_expr = match f.args.as_slice() {
        [ast::FunctionArg::Unnamed(date_expr)] => date_expr,
        _ => {
            return Err(CompilationError::User(format!(
                "Unsupported signature for DATE function: {:?}",
                f
            )));
        }
    };
    let compiled = compile_expression(&date_expr, &ctx)?;
    match compiled {
        date @ CompiledExpression::DateLiteral(_) => Ok(date),
        CompiledExpression::StringLiteral(ref input) => {
            let parsed_date = Utc
                .datetime_from_str(input.as_str(), "%Y-%m-%d %H:%M:%S.%f")
                .map_err(|e| {
                    CompilationError::User(format!(
                        "Unable to parse {}, err: {}",
                        input,
                        e.to_string(),
                    ))
                })?;
            Ok(CompiledExpression::DateLiteral(parsed_date))
        }
        _ => {
            return Err(CompilationError::User(format!(
                "Wrong type of argument (date), must be DateLiteral, actual: {:?}",
                f
            )))
        }
    }
}
fn date_function ( f : & ast :: Function , ctx : & QueryContext ) -> CompilationResult < CompiledExpression > { let date_expr = match f . args . as_slice ( ) { [ ast :: FunctionArg :: Unnamed ( date_expr ) ] => date_expr , _ => { return Err ( CompilationError :: User ( format ! ( " " f ) ) ) ; } } ; let compiled = compile_expression ( & date_expr , & ctx ) ? ; match compiled { date @ CompiledExpression :: DateLiteral ( _ ) => Ok ( date ) , CompiledExpression :: StringLiteral ( ref input ) => { let parsed_date = Utc . datetime_from_str ( input . as_str ( ) , " " ) . map_err ( | e | { CompilationError :: User ( format ! ( " " input e to_string ( ) ) ) } ) ? ; Ok ( CompiledExpression :: DateLiteral ( parsed_date ) ) } _ => { return Err ( CompilationError :: User ( format ! ( " " f ) ) ) } } }
DATE(expr)
Extracts the date part of the date or datetime expression expr.
DATE ( expr ) Extracts the date part of the date or datetime expression expr .
f
&ast::Function
ctx
&QueryContext
f
&ast::Function
ctx
&QueryContext