Add new Array Coerce Cast Metadata object
Currently executor crashes for following query with ORCA ON :
```
CREATE TABLE FOO(a
integer NOT NULL, b double precision[]); SELECT b FROM foo UNION ALL SELECT
ARRAY[90, 90] as Cont_features;
```
In this query, we are appending an integer array (ARRAY[90, 90]) to a double
precision array (foo.b) and hence we need to apply a cast on ARRAY[90, 90] to
generate ARRAY[90, 90]::double precision[].
In gpdb5 there is not direct function available that can cast array of any type
to array of any other type. So in relcache to dxl translator we look into the
array elements and get their type and try to find a cast function for them.
For this query, source type is 23 (integer) and dest type is 701 (double precision)
and we try to find if we have a conversion function for 23 -> 701.
Since that is available we send that function to ORCA as follows:
```
<dxl:MDCast
Mdid="3.1007.1.0;1022.1.0" Name="float8" BinaryCoercible="false"
SourceTypeId="0.1007.1.0" DestinationTypeId="0.1022.1.0"
CastFuncId="0.316.1.0"/>
```
Here we are misinforming ORCA by specifying that function with id 316 is available
to convert type 1007 (integer array) to 1022 (double precision) array.
However Function id 316 is simple int4 to float8 conversion function and it CAN NOT
convert an array of int4 to array of double precision.
ORCA generates a plan using this function but executor crashes while executing this
function because this function can not handle arrays.
This commit adds a new ArrayCoerceCast MetaData object which will be constructed
when we need to convert an array of one type to another; instead of constructing
Cast Metadata.
`CMDArrayCoerceCastGPDB` extends `CMDCastGPDB` in that it includes necessary information
to generate `CScalarArrayCoerceExpr`.
In Relcache Translator on GPDB, we will construct an object of `CMDArrayCoerceCastGPDB`
instead of `CMDCastGPDB` depending on the coercion path determined by `FCastFunc`.
Added relevant test cases.
Ref [#149524459]
Signed-off-by: NEkta Khanna <ekhanna@pivotal.io>
Showing
想要评论请 注册 或 登录