@@ -199,10 +199,37 @@ private DataType updateCharacterTypeLength(DataType dataType) {
199
199
}
200
200
}
201
201
202
+ private void checkKeyColumnType (boolean isOlap ) {
203
+ if (isOlap ) {
204
+ if (type .isFloatLikeType ()) {
205
+ throw new AnalysisException ("Float or double can not used as a key, use decimal instead." );
206
+ } else if (type .isStringType ()) {
207
+ throw new AnalysisException ("String Type should not be used in key column[" + name + "]" );
208
+ } else if (type .isArrayType ()) {
209
+ throw new AnalysisException ("Array can only be used in the non-key column of"
210
+ + " the duplicate table at present." );
211
+ }
212
+ }
213
+ if (type .isBitmapType () || type .isHllType () || type .isQuantileStateType ()) {
214
+ throw new AnalysisException ("Key column can not set complex type:" + name );
215
+ } else if (type .isJsonType ()) {
216
+ throw new AnalysisException ("JsonType type should not be used in key column[" + getName () + "]." );
217
+ } else if (type .isVariantType ()) {
218
+ throw new AnalysisException ("Variant type should not be used in key column[" + getName () + "]." );
219
+ } else if (type .isMapType ()) {
220
+ throw new AnalysisException ("Map can only be used in the non-key column of"
221
+ + " the duplicate table at present." );
222
+ } else if (type .isStructType ()) {
223
+ throw new AnalysisException ("Struct can only be used in the non-key column of"
224
+ + " the duplicate table at present." );
225
+ }
226
+ }
227
+
202
228
/**
203
229
* validate column definition and analyze
204
230
*/
205
- public void validate (boolean isOlap , Set <String > keysSet , boolean isEnableMergeOnWrite , KeysType keysType ) {
231
+ public void validate (boolean isOlap , Set <String > keysSet , Set <String > clusterKeySet , boolean isEnableMergeOnWrite ,
232
+ KeysType keysType ) {
206
233
try {
207
234
FeNameFormat .checkColumnName (name );
208
235
} catch (Exception e ) {
@@ -234,33 +261,7 @@ public void validate(boolean isOlap, Set<String> keysSet, boolean isEnableMergeO
234
261
throw new AnalysisException (
235
262
String .format ("Key column %s can not set aggregation type" , name ));
236
263
}
237
- if (isOlap ) {
238
- if (type .isFloatLikeType ()) {
239
- throw new AnalysisException (
240
- "Float or double can not used as a key, use decimal instead." );
241
- } else if (type .isStringType ()) {
242
- throw new AnalysisException (
243
- "String Type should not be used in key column[" + name + "]" );
244
- } else if (type .isArrayType ()) {
245
- throw new AnalysisException ("Array can only be used in the non-key column of"
246
- + " the duplicate table at present." );
247
- }
248
- }
249
- if (type .isBitmapType () || type .isHllType () || type .isQuantileStateType ()) {
250
- throw new AnalysisException ("Key column can not set complex type:" + name );
251
- } else if (type .isJsonType ()) {
252
- throw new AnalysisException (
253
- "JsonType type should not be used in key column[" + getName () + "]." );
254
- } else if (type .isVariantType ()) {
255
- throw new AnalysisException (
256
- "Variant type should not be used in key column[" + getName () + "]." );
257
- } else if (type .isMapType ()) {
258
- throw new AnalysisException ("Map can only be used in the non-key column of"
259
- + " the duplicate table at present." );
260
- } else if (type .isStructType ()) {
261
- throw new AnalysisException ("Struct can only be used in the non-key column of"
262
- + " the duplicate table at present." );
263
- }
264
+ checkKeyColumnType (isOlap );
264
265
} else if (aggType == null && isOlap ) {
265
266
Preconditions .checkState (keysType != null , "keysType is null" );
266
267
if (keysType .equals (KeysType .DUP_KEYS )) {
@@ -274,6 +275,10 @@ public void validate(boolean isOlap, Set<String> keysSet, boolean isEnableMergeO
274
275
}
275
276
}
276
277
278
+ if (clusterKeySet .contains (name )) {
279
+ checkKeyColumnType (isOlap );
280
+ }
281
+
277
282
if (aggType != null ) {
278
283
// check if aggregate type is valid
279
284
if (aggType != AggregateType .GENERIC
0 commit comments