@@ -41,14 +41,14 @@ type InputTypeSchema interface{} // CompundType, length-one array of *InputSchem
41
41
type OutputSchema interface {} // ValueType, length-one array of OutputSchema, or map of {scalar|ValueType -> OutputSchema} (no *_COLUMN types, compound types, or input options like _default)
42
42
43
43
func inputSchemaValidator (in interface {}) (interface {}, error ) {
44
- return ValidateInputSchema (in , false ) // This casts it to *InputSchema
44
+ return ValidateInputSchema (in , false , false ) // This casts it to *InputSchema
45
45
}
46
46
47
47
func inputSchemaValidatorValueTypesOnly (in interface {}) (interface {}, error ) {
48
- return ValidateInputSchema (in , true ) // This casts it to *InputSchema
48
+ return ValidateInputSchema (in , true , false ) // This casts it to *InputSchema
49
49
}
50
50
51
- func ValidateInputSchema (in interface {}, disallowColumnTypes bool ) (* InputSchema , error ) {
51
+ func ValidateInputSchema (in interface {}, disallowColumnTypes bool , isAlreadyParsed bool ) (* InputSchema , error ) {
52
52
// Check for cortex options vs short form
53
53
if inMap , ok := cast .InterfaceToStrInterfaceMap (in ); ok {
54
54
foundUnderscore , foundNonUnderscore := false , false
@@ -72,7 +72,7 @@ func ValidateInputSchema(in interface{}, disallowColumnTypes bool) (*InputSchema
72
72
InterfaceValidation : & cr.InterfaceValidation {
73
73
Required : true ,
74
74
Validator : func (t interface {}) (interface {}, error ) {
75
- return validateInputTypeSchema (t , disallowColumnTypes )
75
+ return ValidateInputTypeSchema (t , disallowColumnTypes , isAlreadyParsed )
76
76
},
77
77
},
78
78
},
@@ -81,8 +81,10 @@ func ValidateInputSchema(in interface{}, disallowColumnTypes bool) (*InputSchema
81
81
BoolValidation : & cr.BoolValidation {},
82
82
},
83
83
{
84
- StructField : "Default" ,
85
- InterfaceValidation : & cr.InterfaceValidation {},
84
+ StructField : "Default" ,
85
+ InterfaceValidation : & cr.InterfaceValidation {
86
+ AllowExplicitNull : isAlreadyParsed ,
87
+ },
86
88
},
87
89
{
88
90
StructField : "AllowNull" ,
@@ -92,12 +94,14 @@ func ValidateInputSchema(in interface{}, disallowColumnTypes bool) (*InputSchema
92
94
StructField : "MinCount" ,
93
95
Int64PtrValidation : & cr.Int64PtrValidation {
94
96
GreaterThanOrEqualTo : pointer .Int64 (0 ),
97
+ AllowExplicitNull : isAlreadyParsed ,
95
98
},
96
99
},
97
100
{
98
101
StructField : "MaxCount" ,
99
102
Int64PtrValidation : & cr.Int64PtrValidation {
100
103
GreaterThanOrEqualTo : pointer .Int64 (0 ),
104
+ AllowExplicitNull : isAlreadyParsed ,
101
105
},
102
106
},
103
107
},
@@ -117,7 +121,7 @@ func ValidateInputSchema(in interface{}, disallowColumnTypes bool) (*InputSchema
117
121
}
118
122
}
119
123
120
- typeSchema , err := validateInputTypeSchema (in , disallowColumnTypes )
124
+ typeSchema , err := ValidateInputTypeSchema (in , disallowColumnTypes , isAlreadyParsed )
121
125
if err != nil {
122
126
return nil , err
123
127
}
@@ -132,7 +136,7 @@ func ValidateInputSchema(in interface{}, disallowColumnTypes bool) (*InputSchema
132
136
return inputSchema , nil
133
137
}
134
138
135
- func validateInputTypeSchema (in interface {}, disallowColumnTypes bool ) (InputTypeSchema , error ) {
139
+ func ValidateInputTypeSchema (in interface {}, disallowColumnTypes bool , isAlreadyParsed bool ) (InputTypeSchema , error ) {
136
140
// String
137
141
if inStr , ok := in .(string ); ok {
138
142
compoundType , err := CompoundTypeFromString (inStr )
@@ -150,7 +154,7 @@ func validateInputTypeSchema(in interface{}, disallowColumnTypes bool) (InputTyp
150
154
if len (inSlice ) != 1 {
151
155
return nil , ErrorTypeListLength (inSlice )
152
156
}
153
- inputSchema , err := ValidateInputSchema (inSlice [0 ], disallowColumnTypes )
157
+ inputSchema , err := ValidateInputSchema (inSlice [0 ], disallowColumnTypes , isAlreadyParsed )
154
158
if err != nil {
155
159
return nil , errors .Wrap (err , s .Index (0 ))
156
160
}
@@ -182,7 +186,7 @@ func validateInputTypeSchema(in interface{}, disallowColumnTypes bool) (InputTyp
182
186
if disallowColumnTypes && typeKey .IsColumns () {
183
187
return nil , ErrorColumnTypeNotAllowed (typeKey )
184
188
}
185
- valueInputSchema , err := ValidateInputSchema (typeValue , disallowColumnTypes )
189
+ valueInputSchema , err := ValidateInputSchema (typeValue , disallowColumnTypes , isAlreadyParsed )
186
190
if err != nil {
187
191
return nil , errors .Wrap (err , string (typeKey ))
188
192
}
@@ -201,7 +205,7 @@ func validateInputTypeSchema(in interface{}, disallowColumnTypes bool) (InputTyp
201
205
}
202
206
}
203
207
204
- valueInputSchema , err := ValidateInputSchema (value , disallowColumnTypes )
208
+ valueInputSchema , err := ValidateInputSchema (value , disallowColumnTypes , isAlreadyParsed )
205
209
if err != nil {
206
210
return nil , errors .Wrap (err , s .UserStrStripped (key ))
207
211
}
0 commit comments