File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2435,17 +2435,23 @@ impl<S: ContextProvider> SqlToRel<'_, S> {
24352435 span : _,
24362436 } ) = val
24372437 {
2438- let name =
2439- name. replace ( '$' , "" ) . parse :: < usize > ( ) . map_err ( |_| {
2440- plan_datafusion_err ! ( "Can't parse placeholder: {name}" )
2441- } ) ? - 1 ;
2438+ let index = match name[ 1 ..] . parse :: < usize > ( ) . map_err ( |_| {
2439+ plan_datafusion_err ! ( "Can't parse placeholder: {name}" )
2440+ } ) ? {
2441+ 0 => {
2442+ return plan_err ! (
2443+ "Invalid placeholder, zero is not a valid index: {name}"
2444+ ) ;
2445+ }
2446+ index => index - 1 ,
2447+ } ;
24422448 let field = fields. get ( idx) . ok_or_else ( || {
24432449 plan_datafusion_err ! (
24442450 "Placeholder ${} refers to a non existent column" ,
24452451 idx + 1
24462452 )
24472453 } ) ?;
2448- let _ = prepare_param_data_types. insert ( name , Arc :: clone ( field) ) ;
2454+ let _ = prepare_param_data_types. insert ( index , Arc :: clone ( field) ) ;
24492455 }
24502456 }
24512457 }
Original file line number Diff line number Diff line change 1+ # Licensed to the Apache Software Foundation (ASF) under one
2+ # or more contributor license agreements. See the NOTICE file
3+ # distributed with this work for additional information
4+ # regarding copyright ownership. The ASF licenses this file
5+ # to you under the Apache License, Version 2.0 (the
6+ # "License"); you may not use this file except in compliance
7+ # with the License. You may obtain a copy of the License at
8+
9+ # http://www.apache.org/licenses/LICENSE-2.0
10+
11+ # Unless required by applicable law or agreed to in writing,
12+ # software distributed under the License is distributed on an
13+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+ # KIND, either express or implied. See the License for the
15+ # specific language governing permissions and limitations
16+ # under the License.
17+
18+ ##########
19+ ## INSERT VALUES placeholder tests
20+ ##########
21+
22+ statement ok
23+ CREATE TABLE placeholder_zero_insert(x BIGINT NULL);
24+
25+ query error DataFusion error: Error during planning: Invalid placeholder, zero is not a valid index: \$0
26+ EXPLAIN INSERT INTO placeholder_zero_insert VALUES ($0);
You can’t perform that action at this time.
0 commit comments