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