25
25
import org .hibernate .boot .model .relational .Exportable ;
26
26
import org .hibernate .boot .model .relational .Sequence ;
27
27
import org .hibernate .boot .model .relational .SqlStringGenerationContext ;
28
+ import org .hibernate .community .dialect .function .json .SingleStoreJsonArrayAggFunction ;
29
+ import org .hibernate .community .dialect .function .json .SingleStoreJsonArrayAppendFunction ;
30
+ import org .hibernate .community .dialect .function .json .SingleStoreJsonArrayFunction ;
31
+ import org .hibernate .community .dialect .function .json .SingleStoreJsonArrayInsertFunction ;
32
+ import org .hibernate .community .dialect .function .json .SingleStoreJsonExistsFunction ;
33
+ import org .hibernate .community .dialect .function .json .SingleStoreJsonMergepatchFunction ;
34
+ import org .hibernate .community .dialect .function .json .SingleStoreJsonObjectAggFunction ;
35
+ import org .hibernate .community .dialect .function .json .SingleStoreJsonObjectFunction ;
36
+ import org .hibernate .community .dialect .function .json .SingleStoreJsonQueryFunction ;
37
+ import org .hibernate .community .dialect .function .json .SingleStoreJsonRemoveFunction ;
38
+ import org .hibernate .community .dialect .function .json .SingleStoreJsonSetFunction ;
39
+ import org .hibernate .community .dialect .function .json .SingleStoreJsonValueFunction ;
28
40
import org .hibernate .dialect .DatabaseVersion ;
29
41
import org .hibernate .dialect .Dialect ;
30
42
import org .hibernate .dialect .DmlTargetColumnQualifierSupport ;
65
77
import org .hibernate .mapping .UniqueKey ;
66
78
import org .hibernate .metamodel .mapping .EntityMappingType ;
67
79
import org .hibernate .metamodel .spi .RuntimeModelCreationContext ;
80
+ import org .hibernate .query .common .TemporalUnit ;
68
81
import org .hibernate .query .sqm .CastType ;
69
82
import org .hibernate .query .sqm .IntervalType ;
70
- import org .hibernate .query .common .TemporalUnit ;
71
83
import org .hibernate .query .sqm .function .SqmFunctionRegistry ;
72
- import org .hibernate .query .sqm .mutation .spi .AfterUseAction ;
73
- import org .hibernate .query .sqm .mutation .spi .BeforeUseAction ;
74
84
import org .hibernate .query .sqm .mutation .internal .temptable .LocalTemporaryTableInsertStrategy ;
75
85
import org .hibernate .query .sqm .mutation .internal .temptable .LocalTemporaryTableMutationStrategy ;
86
+ import org .hibernate .query .sqm .mutation .spi .AfterUseAction ;
87
+ import org .hibernate .query .sqm .mutation .spi .BeforeUseAction ;
76
88
import org .hibernate .query .sqm .mutation .spi .SqmMultiTableInsertStrategy ;
77
89
import org .hibernate .query .sqm .mutation .spi .SqmMultiTableMutationStrategy ;
78
90
import org .hibernate .query .sqm .produce .function .FunctionParameterType ;
84
96
import org .hibernate .sql .ast .tree .Statement ;
85
97
import org .hibernate .sql .exec .spi .JdbcOperation ;
86
98
import org .hibernate .tool .schema .spi .Exporter ;
87
- import org .hibernate .type .BasicType ;
88
99
import org .hibernate .type .BasicTypeRegistry ;
89
100
import org .hibernate .type .NullType ;
90
101
import org .hibernate .type .SqlTypes ;
100
111
import org .hibernate .type .descriptor .sql .internal .NativeEnumDdlTypeImpl ;
101
112
import org .hibernate .type .descriptor .sql .internal .NativeOrdinalEnumDdlTypeImpl ;
102
113
import org .hibernate .type .descriptor .sql .spi .DdlTypeRegistry ;
114
+ import org .hibernate .type .spi .TypeConfiguration ;
103
115
104
116
import jakarta .persistence .TemporalType ;
105
117
106
118
import static org .hibernate .exception .spi .TemplatedViolatedConstraintNameExtractor .extractUsingTemplate ;
107
- import static org .hibernate .query .sqm .produce .function .FunctionParameterType .ANY ;
108
119
import static org .hibernate .query .sqm .produce .function .FunctionParameterType .NUMERIC ;
109
- import static org .hibernate .query .sqm .produce .function .FunctionParameterType .STRING ;
110
120
import static org .hibernate .type .SqlTypes .BIGINT ;
111
121
import static org .hibernate .type .SqlTypes .BINARY ;
112
122
import static org .hibernate .type .SqlTypes .BIT ;
@@ -504,31 +514,35 @@ protected void registerColumnTypes(TypeContributions typeContributions, ServiceR
504
514
castType ( BINARY ),
505
515
this
506
516
)
507
- .withTypeCapacity ( maxTinyLobLen , "tinyblob" )
508
- .withTypeCapacity ( maxMediumLobLen , "mediumblob" )
509
- .withTypeCapacity ( maxLobLen , "blob" )
510
- .build () );
517
+ .withTypeCapacity ( maxTinyLobLen , "tinyblob" )
518
+ .withTypeCapacity ( maxMediumLobLen , "mediumblob" )
519
+ .withTypeCapacity ( maxLobLen , "blob" )
520
+ .build () );
511
521
512
522
ddlTypeRegistry .addDescriptor ( CapacityDependentDdlType .builder (
513
523
CLOB ,
514
524
columnType ( CLOB ),
515
525
castType ( CHAR ),
516
526
this
517
527
)
518
- .withTypeCapacity ( maxTinyLobLen , "tinytext" )
519
- .withTypeCapacity ( maxMediumLobLen , "mediumtext" )
520
- .withTypeCapacity ( maxLobLen , "text" )
521
- .build () );
528
+ .withTypeCapacity ( maxTinyLobLen , "tinytext" )
529
+ .withTypeCapacity ( maxMediumLobLen , "mediumtext" )
530
+ .withTypeCapacity ( maxLobLen , "text" )
531
+ .build () );
522
532
523
533
ddlTypeRegistry .addDescriptor ( CapacityDependentDdlType .builder (
524
- NCLOB ,
525
- columnType ( NCLOB ),
526
- castType ( NCHAR ),
527
- this
528
- ).withTypeCapacity ( maxTinyLobLen , "tinytext character set utf8" ).withTypeCapacity (
529
- maxMediumLobLen ,
530
- "mediumtext character set utf8"
531
- ).withTypeCapacity ( maxLobLen , "text character set utf8" ).build () );
534
+ NCLOB ,
535
+ columnType ( NCLOB ),
536
+ castType ( NCHAR ),
537
+ this
538
+ )
539
+ .withTypeCapacity (
540
+ maxTinyLobLen ,
541
+ "tinytext character set utf8"
542
+ )
543
+ .withTypeCapacity ( maxMediumLobLen , "mediumtext character set utf8" )
544
+ .withTypeCapacity ( maxLobLen , "text character set utf8" )
545
+ .build () );
532
546
533
547
ddlTypeRegistry .addDescriptor ( new NativeEnumDdlTypeImpl ( this ) );
534
548
ddlTypeRegistry .addDescriptor ( new NativeOrdinalEnumDdlTypeImpl ( this ) );
@@ -586,14 +600,13 @@ public void initializeFunctionRegistry(FunctionContributions functionContributio
586
600
commonFunctionFactory .inverseDistributionOrderedSetAggregates_windowEmulation ();
587
601
commonFunctionFactory .listagg_groupConcat ();
588
602
SqmFunctionRegistry functionRegistry = functionContributions .getFunctionRegistry ();
603
+ final TypeConfiguration typeConfiguration = functionContributions .getTypeConfiguration ();
589
604
BasicTypeRegistry basicTypeRegistry = functionContributions .getTypeConfiguration ().getBasicTypeRegistry ();
590
- functionRegistry
591
- .namedDescriptorBuilder ( "time" )
605
+ functionRegistry .namedDescriptorBuilder ( "time" )
592
606
.setExactArgumentCount ( 1 )
593
607
.setInvariantType ( basicTypeRegistry .resolve ( StandardBasicTypes .STRING ) )
594
608
.register ();
595
- functionRegistry
596
- .patternDescriptorBuilder ( "median" , "median(?1) over ()" )
609
+ functionRegistry .patternDescriptorBuilder ( "median" , "median(?1) over ()" )
597
610
.setInvariantType ( basicTypeRegistry .resolve ( StandardBasicTypes .DOUBLE ) )
598
611
.setExactArgumentCount ( 1 )
599
612
.setParameterTypes ( NUMERIC )
@@ -610,45 +623,18 @@ public void initializeFunctionRegistry(FunctionContributions functionContributio
610
623
.setParameterTypes ( FunctionParameterType .INTEGER )
611
624
.register ();
612
625
functionRegistry .registerAlternateKey ( "char" , "chr" );
613
- BasicType <Boolean > booleanType = basicTypeRegistry .resolve ( StandardBasicTypes .BOOLEAN );
614
- functionRegistry .namedDescriptorBuilder ( "json_array_contains_string" )
615
- .setInvariantType ( booleanType )
616
- .setExactArgumentCount ( 2 )
617
- .setParameterTypes ( ANY , STRING )
618
- .register ();
619
- functionRegistry .registerAlternateKey ( "json_array_contains" , "json_array_contains_string" );
620
- functionRegistry .namedDescriptorBuilder ( "json_array_contains_json" )
621
- .setInvariantType ( booleanType )
622
- .setExactArgumentCount ( 2 )
623
- .setParameterTypes ( ANY , ANY )
624
- .register ();
625
- functionRegistry .namedDescriptorBuilder ( "json_array_contains_double" )
626
- .setInvariantType ( booleanType )
627
- .setExactArgumentCount ( 2 )
628
- .setParameterTypes ( ANY , NUMERIC )
629
- .register ();
630
- functionRegistry .namedDescriptorBuilder ( "json_match_any_exists" )
631
- .setInvariantType ( booleanType )
632
- .setMinArgumentCount ( 1 )
633
- .register ();
634
- functionRegistry .namedDescriptorBuilder ( "json_match_any" )
635
- .setInvariantType ( booleanType )
636
- .setMinArgumentCount ( 1 )
637
- .register ();
638
- functionRegistry .namedDescriptorBuilder ( "json_extract_string" )
639
- .setInvariantType ( basicTypeRegistry .resolve ( StandardBasicTypes .STRING ) )
640
- .setMinArgumentCount ( 1 )
641
- .register ();
642
- functionRegistry .namedDescriptorBuilder ( "json_extract_double" )
643
- .setInvariantType ( basicTypeRegistry .resolve ( StandardBasicTypes .DOUBLE ) )
644
- .setMinArgumentCount ( 1 )
645
- .register ();
646
- functionRegistry .namedDescriptorBuilder ( "json_extract_bigint" )
647
- .setInvariantType ( basicTypeRegistry .resolve ( StandardBasicTypes .BIG_INTEGER ) )
648
- .setMinArgumentCount ( 1 )
649
- .register ();
650
- functionRegistry .registerAlternateKey ( "json_extract" , "json_extract_string" );
651
- functionRegistry .registerAlternateKey ( "json_extract_json" , "json_extract_string" );
626
+ functionRegistry .register ( "json_object" , new SingleStoreJsonObjectFunction ( typeConfiguration ) );
627
+ functionRegistry .register ( "json_array" , new SingleStoreJsonArrayFunction ( typeConfiguration ) );
628
+ functionRegistry .register ( "json_value" , new SingleStoreJsonValueFunction ( typeConfiguration ) );
629
+ functionRegistry .register ( "json_exists" , new SingleStoreJsonExistsFunction ( typeConfiguration ) );
630
+ functionRegistry .register ( "json_query" , new SingleStoreJsonQueryFunction ( typeConfiguration ) );
631
+ functionRegistry .register ( "json_arrayagg" , new SingleStoreJsonArrayAggFunction ( typeConfiguration ) );
632
+ functionRegistry .register ( "json_objectagg" , new SingleStoreJsonObjectAggFunction ( typeConfiguration ) );
633
+ functionRegistry .register ( "json_set" , new SingleStoreJsonSetFunction ( typeConfiguration ) );
634
+ functionRegistry .register ( "json_remove" , new SingleStoreJsonRemoveFunction ( typeConfiguration ) );
635
+ functionRegistry .register ( "json_mergepatch" , new SingleStoreJsonMergepatchFunction ( typeConfiguration ) );
636
+ functionRegistry .register ( "json_array_append" , new SingleStoreJsonArrayAppendFunction ( typeConfiguration ) );
637
+ functionRegistry .register ( "json_array_insert" , new SingleStoreJsonArrayInsertFunction ( typeConfiguration ) );
652
638
}
653
639
654
640
@@ -1253,8 +1239,7 @@ public String getAddForeignKeyConstraintString(
1253
1239
}
1254
1240
1255
1241
@ Override
1256
- public String getAddForeignKeyConstraintString (
1257
- String constraintName , String foreignKeyDefinition ) {
1242
+ public String getAddForeignKeyConstraintString (String constraintName , String foreignKeyDefinition ) {
1258
1243
throw new UnsupportedOperationException ( "SingleStore does not support foreign keys and referential integrity." );
1259
1244
}
1260
1245
0 commit comments