├── .github ├── ISSUE_TEMPLATE │ ├── bug-report.md │ ├── codebase-improvement.md │ └── feature-request.md ├── PULL_REQUEST_TEMPLATE.md └── workflows │ ├── ci-flyway-dialect.yaml │ ├── ci-hibernate-dialect-v5.yaml │ ├── ci-hibernate-dialect.yaml │ ├── ci-jooq-dialect.yaml │ ├── ci-liquibase-dialect.yaml │ ├── ci-shedlock.yaml │ ├── ci-spring-data-jdbc-ydb.yaml │ ├── liquibase-stress-test.yaml │ ├── publish-flyway-dialect.yaml │ ├── publish-hibernate-dialect-v5.yaml │ ├── publish-hibernate-dialect.yaml │ ├── publish-jooq-dialect.yaml │ ├── publish-liquibase-dialect.yaml │ ├── publish-shedlock-ydb.yaml │ └── publish-spring-data-jdbc-ydb.yaml ├── .gitignore ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── SECURITY.md ├── flyway-dialect ├── CHANGELOG.md ├── README.md ├── pom.xml └── src │ ├── main │ ├── java │ │ └── tech │ │ │ └── ydb │ │ │ └── flywaydb │ │ │ └── database │ │ │ ├── YdbConnection.java │ │ │ ├── YdbDatabase.java │ │ │ ├── YdbDatabaseType.java │ │ │ ├── YdbJdbcTemplate.java │ │ │ ├── YdbParser.java │ │ │ ├── YdbSchema.java │ │ │ └── YdbTable.java │ └── resources │ │ └── META-INF │ │ └── services │ │ └── org.flywaydb.core.extensibility.Plugin │ └── test │ ├── java │ └── tech │ │ └── ydb │ │ └── flyway │ │ └── database │ │ ├── YdbFlywayBaseTest.java │ │ ├── YdbFlywayBaselineTest.java │ │ ├── YdbFlywayCleanTest.java │ │ ├── YdbFlywayInfoTest.java │ │ ├── YdbFlywayMigrationTest.java │ │ └── YdbFlywayRepairAndValidateTest.java │ └── resources │ ├── db │ ├── migration-step-1 │ │ └── V1__create_series.sql │ ├── migration-step-2 │ │ ├── V1__create_series.sql │ │ └── V2__create_seasons.sql │ ├── migration-step-3 │ │ ├── V1__create_series.sql │ │ ├── V2__create_seasons.sql │ │ └── V3__create_episodes.sql │ ├── migration-step-4 │ │ ├── V1__create_series.sql │ │ ├── V2__create_seasons.sql │ │ ├── V3__create_episodes.sql │ │ └── V4__load_data.sql │ ├── migration-step-5 │ │ ├── V1__create_series.sql │ │ ├── V2__create_seasons.sql │ │ ├── V3__create_episodes.sql │ │ ├── V4__load_data.sql │ │ └── V5__create_series_title_index.sql │ ├── migration-with-failed │ │ ├── V1__create_series.sql │ │ ├── V2__create_seasons.sql │ │ └── V3__create_episodes.sql │ └── migration │ │ ├── V1__create_series.sql │ │ ├── V2__create_seasons.sql │ │ ├── V3__create_episodes.sql │ │ ├── V4__load_data.sql │ │ ├── V5__create_series_title_index.sql │ │ └── V6__rename_series_title_index.sql │ └── log4j2.xml ├── hibernate-dialect-v5 ├── CHANGELOG.md ├── NOTES.md ├── README.md ├── pom.xml └── src │ ├── main │ └── java │ │ └── tech │ │ └── ydb │ │ └── hibernate │ │ └── dialect │ │ ├── YdbDialect.java │ │ ├── exporter │ │ ├── EmptyExporter.java │ │ └── YdbIndexExporter.java │ │ ├── pagination │ │ └── LimitOffsetLimitHandler.java │ │ └── types │ │ ├── LocalDateTimeType.java │ │ └── LocalDateTimeTypeDescriptor.java │ └── test │ ├── java │ └── tech │ │ └── ydb │ │ └── hibernate │ │ ├── TestUtils.java │ │ ├── student │ │ ├── StudentsRepositoryTest.java │ │ └── entity │ │ │ ├── Course.java │ │ │ ├── Group.java │ │ │ ├── Lecturer.java │ │ │ ├── Mark.java │ │ │ ├── MarkId.java │ │ │ ├── Plan.java │ │ │ ├── PlanId.java │ │ │ └── Student.java │ │ ├── types │ │ ├── Employee.java │ │ └── TypesTest.java │ │ └── user │ │ ├── User.java │ │ └── UserRepositoryTest.java │ └── resources │ ├── import-university.sql │ └── log4j2.xml ├── hibernate-dialect ├── CHANGELOG.md ├── README.md ├── pom.xml └── src │ ├── main │ └── java │ │ └── tech │ │ └── ydb │ │ └── hibernate │ │ └── dialect │ │ ├── YdbDialect.java │ │ ├── code │ │ └── YdbJdbcCode.java │ │ ├── exporter │ │ ├── EmptyExporter.java │ │ └── YdbIndexExporter.java │ │ ├── hint │ │ ├── IndexQueryHintHandler.java │ │ ├── PragmaQueryHintHandler.java │ │ ├── QueryHintHandler.java │ │ └── ScanQueryHintHandler.java │ │ ├── identity │ │ └── YdbIdentityColumnSupport.java │ │ ├── translator │ │ ├── YdbSqlAstTranslator.java │ │ └── YdbSqlAstTranslatorFactory.java │ │ └── types │ │ ├── BigDecimalJavaType.java │ │ ├── DecimalJdbcType.java │ │ ├── InstantJavaType.java │ │ ├── InstantJdbcType.java │ │ ├── LocalDateJavaType.java │ │ ├── LocalDateJdbcType.java │ │ ├── LocalDateTimeJavaType.java │ │ ├── LocalDateTimeJdbcType.java │ │ └── Uint8JdbcType.java │ └── test │ ├── java │ └── tech │ │ └── ydb │ │ └── hibernate │ │ ├── TestUtils.java │ │ ├── auto_inc │ │ ├── GenerationTypeIdentityTest.java │ │ ├── TestEntityFail.java │ │ ├── TestEntityInt.java │ │ ├── TestEntityLong.java │ │ └── TestEntityShort.java │ │ ├── datetime │ │ ├── DataTimeTests.java │ │ └── TestEntity.java │ │ ├── student │ │ ├── StudentsRepositoryTest.java │ │ └── entity │ │ │ ├── Course.java │ │ │ ├── Group.java │ │ │ ├── Lecturer.java │ │ │ ├── Mark.java │ │ │ ├── MarkId.java │ │ │ ├── Plan.java │ │ │ ├── PlanId.java │ │ │ └── Student.java │ │ ├── types │ │ ├── Employee.java │ │ └── TypesTest.java │ │ ├── user │ │ ├── User.java │ │ └── UserRepositoryTest.java │ │ └── ydb_jdbc_code │ │ ├── TestEntity.java │ │ └── YdbJdbcCodeTests.java │ └── resources │ ├── import-university.sql │ └── log4j2.xml ├── jooq-dialect ├── CHANGELOG.md ├── README.md ├── pom.xml └── src │ ├── main │ └── java │ │ ├── org │ │ └── jooq │ │ │ └── impl │ │ │ ├── AbstractYdbAggregateFunction.java │ │ │ ├── AbstractYdbCondition.java │ │ │ ├── AbstractYdbFunction.java │ │ │ ├── ConnectionUtils.java │ │ │ ├── DataTypesUtils.java │ │ │ ├── FieldMapsForUpsertReplace.java │ │ │ ├── ReplaceImpl.java │ │ │ ├── UpsertImpl.java │ │ │ ├── UpsertReplaceImpl.java │ │ │ ├── UpsertReplaceQueryImpl.java │ │ │ ├── YdbListener.java │ │ │ └── YdbTools.java │ │ └── tech │ │ └── ydb │ │ └── jooq │ │ ├── CloseableYdbDSLContext.java │ │ ├── Replace.java │ │ ├── ReplaceQuery.java │ │ ├── Upsert.java │ │ ├── UpsertQuery.java │ │ ├── YDB.java │ │ ├── YdbDSLContext.java │ │ ├── YdbFunction.java │ │ ├── YdbKeywords.java │ │ ├── YdbTypes.java │ │ ├── binding │ │ ├── BindingTools.java │ │ ├── DateBinding.java │ │ ├── DatetimeBinding.java │ │ ├── IntervalBinding.java │ │ ├── JsonBinding.java │ │ ├── JsonDocumentBinding.java │ │ ├── TimestampBinding.java │ │ ├── TzDateBinding.java │ │ ├── TzDatetimeBinding.java │ │ ├── TzTimestampBinding.java │ │ ├── Uint16Binding.java │ │ ├── Uint32Binding.java │ │ ├── Uint64Binding.java │ │ ├── Uint8Binding.java │ │ ├── UuidBinding.java │ │ └── YsonBinding.java │ │ ├── codegen │ │ ├── YdbDatabase.java │ │ ├── YdbGeneratorStrategy.java │ │ ├── YdbIndexDefinition.java │ │ └── YdbTableDefinition.java │ │ ├── dsl │ │ ├── function │ │ │ ├── aggregate │ │ │ │ ├── Avg.java │ │ │ │ ├── AvgIf.java │ │ │ │ ├── BitAnd.java │ │ │ │ ├── BitOr.java │ │ │ │ ├── BitXor.java │ │ │ │ ├── BoolAnd.java │ │ │ │ ├── BoolOr.java │ │ │ │ ├── BoolXor.java │ │ │ │ ├── Correlation.java │ │ │ │ ├── Count.java │ │ │ │ ├── CountDistinctEstimate.java │ │ │ │ ├── CountIf.java │ │ │ │ ├── Covariance.java │ │ │ │ ├── CovariancePopulation.java │ │ │ │ ├── CovarianceSample.java │ │ │ │ ├── HyperLogLog.java │ │ │ │ ├── Max.java │ │ │ │ ├── MaxBy.java │ │ │ │ ├── Median.java │ │ │ │ ├── Min.java │ │ │ │ ├── MinBy.java │ │ │ │ ├── Percentile.java │ │ │ │ ├── PopulationStdDev.java │ │ │ │ ├── PopulationVariance.java │ │ │ │ ├── Some.java │ │ │ │ ├── StdDev.java │ │ │ │ ├── StdDevPopulation.java │ │ │ │ ├── StdDevSample.java │ │ │ │ ├── Sum.java │ │ │ │ ├── SumIf.java │ │ │ │ ├── Variance.java │ │ │ │ ├── VariancePopulation.java │ │ │ │ └── VarianceSample.java │ │ │ └── builtin │ │ │ │ ├── Abs.java │ │ │ │ ├── AddTimezone.java │ │ │ │ ├── AssumeStrict.java │ │ │ │ ├── ByteAt.java │ │ │ │ ├── ClearBit.java │ │ │ │ ├── Coalesce.java │ │ │ │ ├── CurrentTzDate.java │ │ │ │ ├── CurrentTzDatetime.java │ │ │ │ ├── CurrentTzTimestamp.java │ │ │ │ ├── CurrentUtcDate.java │ │ │ │ ├── CurrentUtcDatetime.java │ │ │ │ ├── CurrentUtcTimestamp.java │ │ │ │ ├── EndsWith.java │ │ │ │ ├── Ensure.java │ │ │ │ ├── Find.java │ │ │ │ ├── FlipBit.java │ │ │ │ ├── FromBytes.java │ │ │ │ ├── If.java │ │ │ │ ├── JoinTableRow.java │ │ │ │ ├── Just.java │ │ │ │ ├── Length.java │ │ │ │ ├── Likely.java │ │ │ │ ├── MaxOf.java │ │ │ │ ├── MinOf.java │ │ │ │ ├── NaNvl.java │ │ │ │ ├── Nothing.java │ │ │ │ ├── Pickle.java │ │ │ │ ├── RFind.java │ │ │ │ ├── Random.java │ │ │ │ ├── RandomNumber.java │ │ │ │ ├── RandomUuid.java │ │ │ │ ├── RemoveTimezone.java │ │ │ │ ├── SetBit.java │ │ │ │ ├── StablePickle.java │ │ │ │ ├── StartsWith.java │ │ │ │ ├── Substring.java │ │ │ │ ├── TestBit.java │ │ │ │ ├── ToBytes.java │ │ │ │ ├── Unpickle.java │ │ │ │ └── Unwrap.java │ │ ├── replace │ │ │ ├── ReplaceSetMoreStep.java │ │ │ ├── ReplaceSetStep.java │ │ │ ├── ReplaceValuesStep1.java │ │ │ ├── ReplaceValuesStep10.java │ │ │ ├── ReplaceValuesStep11.java │ │ │ ├── ReplaceValuesStep12.java │ │ │ ├── ReplaceValuesStep13.java │ │ │ ├── ReplaceValuesStep14.java │ │ │ ├── ReplaceValuesStep15.java │ │ │ ├── ReplaceValuesStep16.java │ │ │ ├── ReplaceValuesStep17.java │ │ │ ├── ReplaceValuesStep18.java │ │ │ ├── ReplaceValuesStep19.java │ │ │ ├── ReplaceValuesStep2.java │ │ │ ├── ReplaceValuesStep20.java │ │ │ ├── ReplaceValuesStep21.java │ │ │ ├── ReplaceValuesStep22.java │ │ │ ├── ReplaceValuesStep3.java │ │ │ ├── ReplaceValuesStep4.java │ │ │ ├── ReplaceValuesStep5.java │ │ │ ├── ReplaceValuesStep6.java │ │ │ ├── ReplaceValuesStep7.java │ │ │ ├── ReplaceValuesStep8.java │ │ │ ├── ReplaceValuesStep9.java │ │ │ └── ReplaceValuesStepN.java │ │ └── upsert │ │ │ ├── UpsertSetMoreStep.java │ │ │ ├── UpsertSetStep.java │ │ │ ├── UpsertValuesStep1.java │ │ │ ├── UpsertValuesStep10.java │ │ │ ├── UpsertValuesStep11.java │ │ │ ├── UpsertValuesStep12.java │ │ │ ├── UpsertValuesStep13.java │ │ │ ├── UpsertValuesStep14.java │ │ │ ├── UpsertValuesStep15.java │ │ │ ├── UpsertValuesStep16.java │ │ │ ├── UpsertValuesStep17.java │ │ │ ├── UpsertValuesStep18.java │ │ │ ├── UpsertValuesStep19.java │ │ │ ├── UpsertValuesStep2.java │ │ │ ├── UpsertValuesStep20.java │ │ │ ├── UpsertValuesStep21.java │ │ │ ├── UpsertValuesStep22.java │ │ │ ├── UpsertValuesStep3.java │ │ │ ├── UpsertValuesStep4.java │ │ │ ├── UpsertValuesStep5.java │ │ │ ├── UpsertValuesStep6.java │ │ │ ├── UpsertValuesStep7.java │ │ │ ├── UpsertValuesStep8.java │ │ │ ├── UpsertValuesStep9.java │ │ │ └── UpsertValuesStepN.java │ │ ├── impl │ │ ├── DefaultCloseableYdbDSLContext.java │ │ └── YdbDSLContextImpl.java │ │ └── value │ │ └── YSON.java │ └── test │ └── java │ ├── jooq │ └── generated │ │ └── ydb │ │ ├── DefaultCatalog.java │ │ └── default_schema │ │ ├── DefaultSchema.java │ │ ├── Keys.java │ │ ├── Tables.java │ │ └── tables │ │ ├── DateTable.java │ │ ├── Episodes.java │ │ ├── HardTable.java │ │ ├── Seasons.java │ │ ├── Series.java │ │ └── records │ │ ├── DateTableRecord.java │ │ ├── EpisodesRecord.java │ │ ├── HardTableRecord.java │ │ ├── SeasonsRecord.java │ │ └── SeriesRecord.java │ └── tech │ └── ydb │ └── jooq │ ├── AggregateFunctionTest.java │ ├── BaseTest.java │ ├── FunctionTest.java │ ├── InsertTest.java │ ├── ReplaceTest.java │ ├── SelectTest.java │ ├── UpdateTest.java │ └── UpsertTest.java ├── liquibase-dialect ├── CHANGELOG.md ├── README.md ├── pom.xml ├── src │ ├── main │ │ ├── java │ │ │ └── tech │ │ │ │ └── ydb │ │ │ │ └── liquibase │ │ │ │ ├── change │ │ │ │ ├── InsertDataChangeYdb.java │ │ │ │ ├── LoadDataChangeYdb.java │ │ │ │ └── LoadUpdateDataChangeYdb.java │ │ │ │ ├── database │ │ │ │ └── YdbDatabase.java │ │ │ │ ├── exception │ │ │ │ └── YdbMessageException.java │ │ │ │ ├── lockservice │ │ │ │ └── StandardLockServiceYdb.java │ │ │ │ ├── snapshot │ │ │ │ └── UniqueConstraintSnapshotGeneratorYdb.java │ │ │ │ ├── sqlgenerator │ │ │ │ ├── AddColumnGeneratorYdb.java │ │ │ │ ├── AddDefaultValueGeneratorYdb.java │ │ │ │ ├── AddForeignKeyConstraintGeneratorYdb.java │ │ │ │ ├── AddPrimaryKeyGeneratorYdb.java │ │ │ │ ├── AddUniqueConstraintGeneratorYdb.java │ │ │ │ ├── BaseSqlGeneratorYdb.java │ │ │ │ ├── CreateDatabaseChangeLogLockTableGeneratorYdb.java │ │ │ │ ├── CreateDatabaseChangeLogTableGeneratorYdb.java │ │ │ │ ├── CreateIndexGeneratorYdb.java │ │ │ │ ├── CreateProcedureGeneratorYdb.java │ │ │ │ ├── CreateTableGeneratorYdb.java │ │ │ │ ├── CreateViewGeneratorYdb.java │ │ │ │ ├── DropIndexGeneratorYdb.java │ │ │ │ ├── DropPrimaryKeyGeneratorSql.java │ │ │ │ ├── GetViewDefinitionGeneratorYdb.java │ │ │ │ ├── InsertOrUpdateGeneratorYdb.java │ │ │ │ ├── RenameColumnGeneratorYdb.java │ │ │ │ └── RenameTableGeneratorYdb.java │ │ │ │ └── type │ │ │ │ ├── BaseTypeYdb.java │ │ │ │ ├── BoolTypeYdb.java │ │ │ │ ├── BytesTypeYdb.java │ │ │ │ ├── DateTypeYdb.java │ │ │ │ ├── DecimalTypeYdb.java │ │ │ │ ├── DoubleTypeYdb.java │ │ │ │ ├── FloatTypeYdb.java │ │ │ │ ├── IntTypeYdb.java │ │ │ │ ├── IntervalTypeYdb.java │ │ │ │ ├── JsonDocumentTypeYdb.java │ │ │ │ ├── JsonTypeYdb.java │ │ │ │ ├── LongTypeYdb.java │ │ │ │ ├── SmallIntTypeYdb.java │ │ │ │ ├── TextTypeYdb.java │ │ │ │ ├── TimeTypeYdb.java │ │ │ │ ├── TimestampTypeYdb.java │ │ │ │ ├── TinyIntTypeYdb.java │ │ │ │ ├── Uint16TypeYdb.java │ │ │ │ ├── Uint32TypeYdb.java │ │ │ │ ├── Uint64TypeYdb.java │ │ │ │ ├── Uint8TypeYdb.java │ │ │ │ └── UuidTypeYdb.java │ │ └── resources │ │ │ └── META-INF │ │ │ └── services │ │ │ ├── liquibase.change.Change │ │ │ ├── liquibase.database.Database │ │ │ ├── liquibase.datatype.LiquibaseDataType │ │ │ ├── liquibase.lockservice.LockService │ │ │ ├── liquibase.snapshot.SnapshotGenerator │ │ │ └── liquibase.sqlgenerator.SqlGenerator │ └── test │ │ ├── java │ │ └── tech │ │ │ └── ydb │ │ │ └── liquibase │ │ │ ├── BaseTest.java │ │ │ ├── YdbDatabaseCSVLoadTest.java │ │ │ ├── YdbDatabaseFailSqlStatementMessagesTest.java │ │ │ ├── YdbDatabaseGenerateChangeLogTest.java │ │ │ ├── YdbDatabaseLiquibaseAllTypesTableTest.java │ │ │ ├── YdbDatabaseLiquibaseChangeLogStateTest.java │ │ │ ├── YdbDatabaseReadBigChangeLogTest.java │ │ │ ├── YdbDatabaseRollbackChangesetTest.java │ │ │ └── YdbDatabaseUpdateChangeLogTest.java │ │ └── resources │ │ ├── changelogs │ │ ├── changelog-init.xml │ │ ├── changelog-load-csv.xml │ │ ├── changelog-step-1.xml │ │ ├── changelog-step-2.xml │ │ ├── changelog-step-3.xml │ │ ├── changelog_all_types_table.xml │ │ ├── changelog_batch_load_data.xml │ │ ├── csv │ │ │ ├── episodes.csv │ │ │ ├── test-insert.csv │ │ │ └── test-upsert.csv │ │ ├── migration-fail │ │ │ ├── table_has_auto_increment.xml │ │ │ ├── table_has_default_value.xml │ │ │ ├── table_has_foreign_key.xml │ │ │ ├── table_has_unique_constraint.xml │ │ │ └── table_not_has_primary_key.xml │ │ ├── migration │ │ │ ├── all_types_table.xml │ │ │ ├── alter_table.xml │ │ │ ├── seasons_and_episodes.xml │ │ │ └── series.xml │ │ └── update │ │ │ ├── changelog-step-1.xml │ │ │ ├── changelog-step-2.xml │ │ │ ├── create-table.xml │ │ │ ├── insert.xml │ │ │ └── update.xml │ │ ├── liquibase.properties │ │ └── logging.properties └── stress-test │ ├── README.md │ ├── changelog │ ├── changelog-0.xml │ ├── changelog-1.xml │ ├── changelog-2.xml │ ├── changelog-3.xml │ ├── changelog-4.xml │ ├── changelog-5.xml │ ├── changelog-6.xml │ ├── csv │ │ └── episodes.csv │ └── migration │ │ ├── add-column-episodes.xml │ │ ├── all_types_table.xml │ │ ├── create-index-episodes.xml │ │ ├── episodes.xml │ │ ├── load-csv-to-episodes.xml │ │ └── rename-table-episodes.xml │ ├── go.mod │ ├── go.sum │ ├── liquibase.properties │ ├── liquibase_stress_test.go │ └── run.sh ├── shedlock-ydb ├── pom.xml └── src │ ├── main │ ├── java │ │ └── tech │ │ │ └── ydb │ │ │ └── lock │ │ │ └── provider │ │ │ ├── YdbJDBCLockProvider.java │ │ │ ├── YdbLockProviderConfiguration.java │ │ │ └── package-info.java │ └── resources │ │ └── META-INF │ │ └── spring │ │ └── org.springframework.boot.autoconfigure.AutoConfiguration.imports │ └── test │ ├── java │ └── tech │ │ └── ydb │ │ └── lock │ │ └── provider │ │ ├── TestApp.java │ │ └── YdbLockProviderTest.java │ └── resources │ └── application.properties └── spring-data-jdbc-ydb ├── CHANGELOG.md ├── README.md ├── pom.xml └── src ├── main ├── java │ └── tech │ │ └── ydb │ │ └── data │ │ ├── core │ │ ├── convert │ │ │ ├── YQLType.java │ │ │ ├── YdbConst.java │ │ │ ├── YdbMappingJdbcConverter.java │ │ │ ├── YdbSqlType.java │ │ │ ├── YdbType.java │ │ │ ├── annotation │ │ │ │ └── YdbType.java │ │ │ └── package-info.java │ │ └── dialect │ │ │ ├── YdbDialect.java │ │ │ └── package-info.java │ │ └── repository │ │ ├── ViewIndex.java │ │ ├── config │ │ ├── AbstractYdbJdbcConfiguration.java │ │ ├── JdbcRepositoryBeanPostProcessor.java │ │ ├── YdbDialectProvider.java │ │ └── package-info.java │ │ └── package-info.java └── resources │ └── META-INF │ └── spring.factories └── test ├── java └── tech │ └── ydb │ └── data │ ├── YdbBaseTest.java │ ├── YdbJdbcConfiguration.java │ ├── all_types_table │ ├── AllTypesTableTest.java │ ├── entity │ │ └── AllTypesEntity.java │ └── repository │ │ └── AllTypesEntityRepository.java │ ├── books │ ├── RepositoriesIntegrationTest.java │ ├── entity │ │ ├── Author.java │ │ ├── Book.java │ │ ├── BookAuthor.java │ │ └── Review.java │ └── repository │ │ ├── AuthorRepository.java │ │ ├── BookRepository.java │ │ └── ReviewRepository.java │ └── repository │ └── config │ └── JdbcRepositoryBeanPostProcessorTest.java └── resources ├── application.properties └── changelogs ├── all_types_table.yaml ├── books.yaml ├── changelog.yaml ├── insert.sql └── insert_all_types_table.csv /.github/ISSUE_TEMPLATE/bug-report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug Report 3 | about: Create a report to help us improve 4 | title: "[BUG]: " 5 | labels: bug 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 1. Go to '...' 16 | 2. Click on '....' 17 | 3. Scroll down to '....' 18 | 4. See error 19 | 20 | **Expected behavior** 21 | A clear and concise description of what you expected to happen. 22 | 23 | **Screenshots** 24 | If applicable, add screenshots to help explain your problem. 25 | 26 | **Desktop (please complete the following information):** 27 | - OS: [e.g. iOS] 28 | - Browser [e.g. chrome, safari] 29 | - Version [e.g. 22] 30 | 31 | **Smartphone (please complete the following information):** 32 | - Device: [e.g. iPhone6] 33 | - OS: [e.g. iOS8.1] 34 | - Browser [e.g. stock browser, safari] 35 | - Version [e.g. 22] 36 | 37 | **Additional context** 38 | Add any other context about the problem here. 39 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/codebase-improvement.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Codebase improvement 3 | about: Provide your feedback for the existing codebase. Suggest a better solution 4 | for algorithms, development tools, etc. 5 | title: 'dev: ' 6 | labels: '' 7 | assignees: '' 8 | 9 | --- 10 | 11 | 12 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature-request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature Request 3 | about: Suggest an idea for this project 4 | title: 'feat: ' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | ## Pull request type 4 | 5 | 6 | 7 | Please check the type of change your PR introduces: 8 | 9 | - [ ] Bugfix 10 | - [ ] Feature 11 | - [ ] Code style update (formatting, renaming) 12 | - [ ] Refactoring (no functional changes, no api changes) 13 | - [ ] Build related changes 14 | - [ ] Documentation content changes 15 | - [ ] Other (please describe): 16 | 17 | ## What is the current behavior? 18 | 19 | 20 | 21 | Issue Number: N/A 22 | 23 | ## What is the new behavior? 24 | 25 | 26 | 27 | - 28 | - 29 | - 30 | 31 | ## Other information 32 | 33 | 34 | -------------------------------------------------------------------------------- /.github/workflows/ci-flyway-dialect.yaml: -------------------------------------------------------------------------------- 1 | name: YDB Flyway Dialect CI with Maven 2 | 3 | on: 4 | push: 5 | paths: 6 | - 'flyway-dialect/**' 7 | branches: 8 | - main 9 | pull_request: 10 | paths: 11 | - 'flyway-dialect/**' 12 | 13 | env: 14 | MAVEN_ARGS: --batch-mode --update-snapshots -Dstyle.color=always 15 | 16 | jobs: 17 | build: 18 | name: YDB Flyway Dialect 19 | runs-on: ubuntu-latest 20 | 21 | strategy: 22 | matrix: 23 | java: [ '17', '21' ] 24 | 25 | steps: 26 | - uses: actions/checkout@v4 27 | 28 | - name: Set up JDK ${{matrix.java}} 29 | uses: actions/setup-java@v4 30 | with: 31 | java-version: ${{matrix.java}} 32 | distribution: 'temurin' 33 | cache: maven 34 | 35 | - name: Extract Flyway Dialect version 36 | working-directory: ./flyway-dialect 37 | run: | 38 | VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout) 39 | echo "FLYWAY_DIALECT_VERSION=$VERSION" >> "$GITHUB_ENV" 40 | 41 | - name: Download Flyway Dialect dependencies 42 | working-directory: ./flyway-dialect 43 | run: mvn $MAVEN_ARGS dependency:go-offline 44 | 45 | - name: Build Flyway Dialect 46 | working-directory: ./flyway-dialect 47 | run: mvn $MAVEN_ARGS clean test 48 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Maven build folders 2 | **/target 3 | 4 | # NetBeans project files 5 | **/nbactions.xml 6 | **/nb-configuration.xml 7 | 8 | # Intellij project files 9 | **/.idea/ 10 | **/*.iml 11 | **/*.iws 12 | **/*.ipr -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Notice to external contributors 2 | 3 | ## Common 4 | 5 | YDB is a free and open project and we appreciate to receive contributions from our community. 6 | 7 | ## Contributing code changes 8 | 9 | If you would like to contribute a new feature or a bug fix, please discuss your idea first on the GitHub issue. 10 | If there is no issue for your idea, please open one. It may be that somebody is already working on it, 11 | or that there are some complex obstacles that you should know about before starting the implementation. 12 | Usually there are several ways to fix a problem and it is important to find the right approach before spending time on a PR 13 | that cannot be merged. 14 | 15 | ## Provide a contribution 16 | 17 | To make a contribution you should submit a pull request. There will probably be discussion about the pull request and, if any changes are needed, we would love to work with you to get your pull request merged. 18 | 19 | ## Other questions 20 | 21 | If you have any questions, please mail us at info@ydb.tech. -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | 3 | ## Reporting a Vulnerability 4 | 5 | We're extremely grateful for security researchers and users who report vulnerabilities they discovered in YDB. All reports are thoroughly investigated. 6 | 7 | To report a potential vulnerability in YDB please email details to [security@ydb.tech](mailto:security@ydb.tech). 8 | 9 | ### When Should I Report a Vulnerability? 10 | 11 | - You think you discovered a potential security vulnerability in YDB 12 | - You are unsure how a vulnerability affects YDB 13 | 14 | ## Security Vulnerability Response 15 | 16 | Each report is acknowledged and analyzed by YDB maintainers within 5 working days. 17 | We will keep the reporter informed about the issue progress. 18 | 19 | ## Public Disclosure Timing 20 | 21 | A public disclosure date is negotiated by YDB maintainers and the bug submitter. 22 | We prefer to fully disclose the bug as soon as possible once a mitigation is available for YDB users. 23 | It is reasonable to delay disclosure when the bug or the fix is not yet fully understood, 24 | the solution is not well-tested, or for vendor coordination. 25 | The timeframe for disclosure is from immediate (especially if it's already publicly known) to 90 days. 26 | For a vulnerability with a straightforward mitigation, we expect report date to disclosure date to be on the order of 7 days. 27 | -------------------------------------------------------------------------------- /flyway-dialect/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 1.0.0 ## 2 | 3 | - Stable version 4 | 5 | --- 6 | 7 | ## 1.0.0-RC0 ## 8 | 9 | * Implementation distributed lock 10 | * Supported main commands how `migration`, `info`, `validate`, `baseline`, `clean`, `repair` 11 | * Mock YDB schema which it doesn't support (<= 24.1) 12 | * Extension JdbcTemplate via YdbJdbcTemplate 13 | * Implementation of all main classes from packages `org.flywaydb.core.internal.database.base` 14 | -------------------------------------------------------------------------------- /flyway-dialect/src/main/java/tech/ydb/flywaydb/database/YdbConnection.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.flywaydb.database; 2 | 3 | import org.flywaydb.core.internal.database.base.Connection; 4 | 5 | /** 6 | * @author Kirill Kurdyukov 7 | */ 8 | public class YdbConnection extends Connection { 9 | 10 | private static final String YDB_SCHEMA_NAME = ""; 11 | 12 | protected YdbConnection(YdbDatabase database, java.sql.Connection connection) { 13 | super(database, connection); 14 | 15 | this.jdbcTemplate = new YdbJdbcTemplate(connection, database.getDatabaseType()); 16 | } 17 | 18 | @Override 19 | protected String getCurrentSchemaNameOrSearchPath() { 20 | return YDB_SCHEMA_NAME; // schema isn't supported 21 | } 22 | 23 | @Override 24 | public YdbSchema getSchema(String name) { 25 | return new YdbSchema(jdbcTemplate, database, YDB_SCHEMA_NAME); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /flyway-dialect/src/main/java/tech/ydb/flywaydb/database/YdbParser.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.flywaydb.database; 2 | 3 | import org.flywaydb.core.api.configuration.Configuration; 4 | import org.flywaydb.core.internal.parser.Parser; 5 | import org.flywaydb.core.internal.parser.ParsingContext; 6 | 7 | /** 8 | * @author Kirill Kurdyukov 9 | */ 10 | public class YdbParser extends Parser { 11 | 12 | protected YdbParser(Configuration configuration, ParsingContext parsingContext) { 13 | super(configuration, parsingContext, 3); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /flyway-dialect/src/main/resources/META-INF/services/org.flywaydb.core.extensibility.Plugin: -------------------------------------------------------------------------------- 1 | tech.ydb.flywaydb.database.YdbDatabaseType -------------------------------------------------------------------------------- /flyway-dialect/src/test/java/tech/ydb/flyway/database/YdbFlywayInfoTest.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.flyway.database; 2 | 3 | import static org.junit.jupiter.api.Assertions.assertEquals; 4 | import org.junit.jupiter.api.Test; 5 | 6 | /** 7 | * @author Kirill Kurdyukov 8 | */ 9 | public class YdbFlywayInfoTest extends YdbFlywayBaseTest { 10 | 11 | @Test 12 | void simpleTest() { 13 | createFlyway("classpath:db/migration-step-3").load().migrate(); 14 | 15 | var flyway = createFlyway("classpath:db/migration").load(); 16 | 17 | var info = flyway.info(); 18 | 19 | assertEquals(3, info.applied().length); 20 | assertEquals(6, info.all().length); 21 | 22 | flyway.migrate(); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /flyway-dialect/src/test/resources/db/migration-step-1/V1__create_series.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE series -- series is the table name. 2 | ( -- Must be unique within the folder. 3 | series_id Int64, 4 | title Text, 5 | series_info Text, 6 | release_date Int64, 7 | PRIMARY KEY (series_id) -- The primary key is a column or 8 | -- combination of columns that uniquely identifies 9 | -- each table row (contains only 10 | -- non-repeating values). A table can have 11 | -- only one primary key. For every table 12 | -- in YDB, the primary key is required. 13 | ); -------------------------------------------------------------------------------- /flyway-dialect/src/test/resources/db/migration-step-2/V1__create_series.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE series -- series is the table name. 2 | ( -- Must be unique within the folder. 3 | series_id Int64, 4 | title Text, 5 | series_info Text, 6 | release_date Int64, 7 | PRIMARY KEY (series_id) -- The primary key is a column or 8 | -- combination of columns that uniquely identifies 9 | -- each table row (contains only 10 | -- non-repeating values). A table can have 11 | -- only one primary key. For every table 12 | -- in YDB, the primary key is required. 13 | ); -------------------------------------------------------------------------------- /flyway-dialect/src/test/resources/db/migration-step-2/V2__create_seasons.sql: -------------------------------------------------------------------------------- 1 | 2 | CREATE TABLE seasons 3 | ( 4 | series_id Uint64, 5 | season_id Uint64, 6 | title Utf8, 7 | first_aired Uint64, 8 | last_aired Uint64, 9 | PRIMARY KEY (series_id, season_id) 10 | ); -------------------------------------------------------------------------------- /flyway-dialect/src/test/resources/db/migration-step-3/V1__create_series.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE series -- series is the table name. 2 | ( -- Must be unique within the folder. 3 | series_id Int64, 4 | title Text, 5 | series_info Text, 6 | release_date Int64, 7 | PRIMARY KEY (series_id) -- The primary key is a column or 8 | -- combination of columns that uniquely identifies 9 | -- each table row (contains only 10 | -- non-repeating values). A table can have 11 | -- only one primary key. For every table 12 | -- in YDB, the primary key is required. 13 | ); -------------------------------------------------------------------------------- /flyway-dialect/src/test/resources/db/migration-step-3/V2__create_seasons.sql: -------------------------------------------------------------------------------- 1 | 2 | CREATE TABLE seasons 3 | ( 4 | series_id Uint64, 5 | season_id Uint64, 6 | title Utf8, 7 | first_aired Uint64, 8 | last_aired Uint64, 9 | PRIMARY KEY (series_id, season_id) 10 | ); -------------------------------------------------------------------------------- /flyway-dialect/src/test/resources/db/migration-step-3/V3__create_episodes.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE episodes 2 | ( 3 | series_id Uint64, 4 | season_id Uint64, 5 | episode_id Uint64, 6 | title Utf8, 7 | air_date Uint64, 8 | PRIMARY KEY (series_id, season_id, episode_id) 9 | ); -------------------------------------------------------------------------------- /flyway-dialect/src/test/resources/db/migration-step-4/V1__create_series.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE series -- series is the table name. 2 | ( -- Must be unique within the folder. 3 | series_id Int64, 4 | title Text, 5 | series_info Text, 6 | release_date Int64, 7 | PRIMARY KEY (series_id) -- The primary key is a column or 8 | -- combination of columns that uniquely identifies 9 | -- each table row (contains only 10 | -- non-repeating values). A table can have 11 | -- only one primary key. For every table 12 | -- in YDB, the primary key is required. 13 | ); -------------------------------------------------------------------------------- /flyway-dialect/src/test/resources/db/migration-step-4/V2__create_seasons.sql: -------------------------------------------------------------------------------- 1 | 2 | CREATE TABLE seasons 3 | ( 4 | series_id Uint64, 5 | season_id Uint64, 6 | title Utf8, 7 | first_aired Uint64, 8 | last_aired Uint64, 9 | PRIMARY KEY (series_id, season_id) 10 | ); -------------------------------------------------------------------------------- /flyway-dialect/src/test/resources/db/migration-step-4/V3__create_episodes.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE episodes 2 | ( 3 | series_id Uint64, 4 | season_id Uint64, 5 | episode_id Uint64, 6 | title Utf8, 7 | air_date Uint64, 8 | PRIMARY KEY (series_id, season_id, episode_id) 9 | ); -------------------------------------------------------------------------------- /flyway-dialect/src/test/resources/db/migration-step-5/V1__create_series.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE series -- series is the table name. 2 | ( -- Must be unique within the folder. 3 | series_id Int64, 4 | title Text, 5 | series_info Text, 6 | release_date Int64, 7 | PRIMARY KEY (series_id) -- The primary key is a column or 8 | -- combination of columns that uniquely identifies 9 | -- each table row (contains only 10 | -- non-repeating values). A table can have 11 | -- only one primary key. For every table 12 | -- in YDB, the primary key is required. 13 | ); -------------------------------------------------------------------------------- /flyway-dialect/src/test/resources/db/migration-step-5/V2__create_seasons.sql: -------------------------------------------------------------------------------- 1 | 2 | CREATE TABLE seasons 3 | ( 4 | series_id Uint64, 5 | season_id Uint64, 6 | title Utf8, 7 | first_aired Uint64, 8 | last_aired Uint64, 9 | PRIMARY KEY (series_id, season_id) 10 | ); -------------------------------------------------------------------------------- /flyway-dialect/src/test/resources/db/migration-step-5/V3__create_episodes.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE episodes 2 | ( 3 | series_id Uint64, 4 | season_id Uint64, 5 | episode_id Uint64, 6 | title Utf8, 7 | air_date Uint64, 8 | PRIMARY KEY (series_id, season_id, episode_id) 9 | ); -------------------------------------------------------------------------------- /flyway-dialect/src/test/resources/db/migration-step-5/V5__create_series_title_index.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE `series` ADD INDEX `title_index` GLOBAL ON (`title`); 2 | -------------------------------------------------------------------------------- /flyway-dialect/src/test/resources/db/migration-with-failed/V1__create_series.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE series -- series is the table name. 2 | ( -- Must be unique within the folder. 3 | series_id Int64, 4 | title Text, 5 | series_info Text, 6 | release_date Int64, 7 | PRIMARY KEY (series_id) -- The primary key is a column or 8 | -- combination of columns that uniquely identifies 9 | -- each table row (contains only 10 | -- non-repeating values). A table can have 11 | -- only one primary key. For every table 12 | -- in YDB, the primary key is required. 13 | ); -------------------------------------------------------------------------------- /flyway-dialect/src/test/resources/db/migration-with-failed/V2__create_seasons.sql: -------------------------------------------------------------------------------- 1 | 2 | CREATE TABLE seasons 3 | ( 4 | series_id Uint64, 5 | season_id Uint64, 6 | title Utf8, 7 | first_aired Uint64, 8 | last_aired Uint64, 9 | PRIMARY KEY (series_id, season_id) 10 | ); -------------------------------------------------------------------------------- /flyway-dialect/src/test/resources/db/migration-with-failed/V3__create_episodes.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE episodes 2 | ( 3 | series_id STRANGE, 4 | season_id Uint64, 5 | episode_id Uint64, 6 | title Utf8, 7 | air_date Uint64, 8 | PRIMARY KEY (series_id, season_id, episode_id) 9 | ); -------------------------------------------------------------------------------- /flyway-dialect/src/test/resources/db/migration/V1__create_series.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE series -- series is the table name. 2 | ( -- Must be unique within the folder. 3 | series_id Int64, 4 | title Text, 5 | series_info Text, 6 | release_date Int64, 7 | PRIMARY KEY (series_id) -- The primary key is a column or 8 | -- combination of columns that uniquely identifies 9 | -- each table row (contains only 10 | -- non-repeating values). A table can have 11 | -- only one primary key. For every table 12 | -- in YDB, the primary key is required. 13 | ); -------------------------------------------------------------------------------- /flyway-dialect/src/test/resources/db/migration/V2__create_seasons.sql: -------------------------------------------------------------------------------- 1 | 2 | CREATE TABLE seasons 3 | ( 4 | series_id Uint64, 5 | season_id Uint64, 6 | title Utf8, 7 | first_aired Uint64, 8 | last_aired Uint64, 9 | PRIMARY KEY (series_id, season_id) 10 | ); -------------------------------------------------------------------------------- /flyway-dialect/src/test/resources/db/migration/V3__create_episodes.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE episodes 2 | ( 3 | series_id Uint64, 4 | season_id Uint64, 5 | episode_id Uint64, 6 | title Utf8, 7 | air_date Uint64, 8 | PRIMARY KEY (series_id, season_id, episode_id) 9 | ); -------------------------------------------------------------------------------- /flyway-dialect/src/test/resources/db/migration/V5__create_series_title_index.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE `series` ADD INDEX `title_index` GLOBAL ON (`title`); 2 | -------------------------------------------------------------------------------- /flyway-dialect/src/test/resources/db/migration/V6__rename_series_title_index.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE `series` RENAME INDEX `title_index` TO `title_index_new`; 2 | -------------------------------------------------------------------------------- /flyway-dialect/src/test/resources/log4j2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /hibernate-dialect-v5/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 0.9.3 ## 2 | 3 | - Supported enum field of Entity 4 | 5 | ## 0.9.2 ## 6 | 7 | - Supported LocalDateTime with datetime YDB primitive type and mapped to java.sql.Types.TIME 8 | 9 | ## 0.9.1 ## 10 | 11 | - Full CRUD operations 12 | - Support LIKE / ILIKE statement with ESCAPE 13 | - Support LIMIT ? OFFSET ? statement 14 | - @OneToOne, @ManyToMany, @OneToMany, @ManyToOne 15 | - Generate table schema -------------------------------------------------------------------------------- /hibernate-dialect-v5/NOTES.md: -------------------------------------------------------------------------------- 1 | #### 1. ORDER BY ? 2 | 3 | The ORDER BY clause generates SQL that uses the original 4 | column names of the table, instead of the 5 | aliases that were previously specified. 6 | At the moment, this is an incorrect YDB request. 7 | 8 | ```sql 9 | select 10 | student0_.studentId as studenti1_1_, 11 | student0_.groupId as groupid2_1_, 12 | student0_.name as name3_1_ 13 | from Students student0_ order by student0_.name_ 14 | ``` 15 | 16 | At the moment, our solution to this problem is 17 | to use native SQL for queries or upgrade to Hibernate 6. 18 | 19 | #### 2. ESCAPE ? GENERATED BY Spring Data JPA 20 | 21 | The Spring Data JPA framework generates the `LAKE ? ESCAPE ?` clause 22 | when the repository method signature contains the substring `ByFieldContains`. 23 | At the moment, this is an incorrect YDB request. ESCAPE don't have param. 24 | 25 | --- 26 | 27 | Here is an example solution to problems 1 and 2 using native SQL: 28 | 29 | ```kotlin 30 | @Query( 31 | "SELECT * FROM books WHERE books.title LIKE %:title% ORDER BY books.publication_date", 32 | nativeQuery = true 33 | ) 34 | fun findBooksByTitleContainsOrderByPublicationDate(title: String, pageable: Pageable): Slice 35 | ``` 36 | -------------------------------------------------------------------------------- /hibernate-dialect-v5/src/main/java/tech/ydb/hibernate/dialect/exporter/EmptyExporter.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.hibernate.dialect.exporter; 2 | 3 | import org.hibernate.boot.Metadata; 4 | import org.hibernate.boot.model.relational.Exportable; 5 | import org.hibernate.tool.schema.spi.Exporter; 6 | 7 | /** 8 | * @author Kirill Kurdyukov 9 | */ 10 | public class EmptyExporter implements Exporter { 11 | 12 | @Override 13 | public String[] getSqlCreateStrings(T exportable, Metadata metadata) { 14 | return NO_COMMANDS; 15 | } 16 | 17 | @Override 18 | public String[] getSqlDropStrings(T exportable, Metadata metadata) { 19 | return NO_COMMANDS; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /hibernate-dialect-v5/src/main/java/tech/ydb/hibernate/dialect/pagination/LimitOffsetLimitHandler.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.hibernate.dialect.pagination; 2 | 3 | import org.hibernate.dialect.pagination.AbstractLimitHandler; 4 | import org.hibernate.dialect.pagination.LimitHelper; 5 | import org.hibernate.engine.spi.RowSelection; 6 | 7 | /** 8 | * @author Kirill Kurdyukov 9 | */ 10 | public class LimitOffsetLimitHandler extends AbstractLimitHandler { 11 | 12 | public final static LimitOffsetLimitHandler INSTANCE = new LimitOffsetLimitHandler(); 13 | 14 | @Override 15 | public String processSql(String sql, RowSelection selection) { 16 | final boolean hasOffset = LimitHelper.hasFirstRow(selection); 17 | return sql + (hasOffset ? " limit ? offset ?" : " limit ?"); 18 | } 19 | 20 | @Override 21 | public boolean supportsLimit() { 22 | return true; 23 | } 24 | 25 | @Override 26 | public boolean bindLimitParametersInReverseOrder() { 27 | return true; // correct LIMIT ? OFFSET ? 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /hibernate-dialect-v5/src/test/java/tech/ydb/hibernate/student/entity/Group.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.hibernate.student.entity; 2 | 3 | import lombok.Getter; 4 | import lombok.Setter; 5 | 6 | import javax.persistence.Column; 7 | import javax.persistence.Entity; 8 | import javax.persistence.Id; 9 | import javax.persistence.Index; 10 | import javax.persistence.NamedQuery; 11 | import javax.persistence.OneToMany; 12 | import javax.persistence.Table; 13 | import java.util.List; 14 | 15 | /** 16 | * @author Kirill Kurdyukov 17 | */ 18 | @Getter 19 | @Setter 20 | @Entity 21 | @Table(name = "Groups", indexes = @Index(name = "group_name_index", columnList = "GroupName")) 22 | @NamedQuery( 23 | name = "Group.findGroups", 24 | query = "SELECT g FROM Group g " + 25 | "JOIN Plan p ON g.id = p.planId.groupId " + 26 | "JOIN Lecturer l ON p.planId.lecturerId = l.id " + 27 | "WHERE p.planId.courseId = :CourseId and l.id = :LecturerId" 28 | ) 29 | public class Group { 30 | 31 | @Id 32 | @Column(name = "GroupId") 33 | private int id; 34 | 35 | @Column(name = "GroupName") 36 | private String name; 37 | 38 | @OneToMany(mappedBy = "group") 39 | private List students; 40 | 41 | @Override 42 | public int hashCode() { 43 | return id; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /hibernate-dialect-v5/src/test/java/tech/ydb/hibernate/student/entity/Lecturer.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.hibernate.student.entity; 2 | 3 | import lombok.Getter; 4 | import lombok.Setter; 5 | 6 | import javax.persistence.Column; 7 | import javax.persistence.Entity; 8 | import javax.persistence.Id; 9 | import javax.persistence.Table; 10 | 11 | /** 12 | * @author Kirill Kurdyukov 13 | */ 14 | @Getter 15 | @Setter 16 | @Entity 17 | @Table(name = "Lecturers") 18 | public class Lecturer { 19 | 20 | @Id 21 | @Column(name = "LecturerId") 22 | private int id; 23 | 24 | @Column(name = "LecturerName") 25 | private String name; 26 | } 27 | -------------------------------------------------------------------------------- /hibernate-dialect-v5/src/test/java/tech/ydb/hibernate/student/entity/Mark.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.hibernate.student.entity; 2 | 3 | import lombok.Data; 4 | 5 | import javax.persistence.Column; 6 | import javax.persistence.EmbeddedId; 7 | import javax.persistence.Entity; 8 | import javax.persistence.Table; 9 | 10 | /** 11 | * @author Kirill Kurdyukov 12 | */ 13 | @Data 14 | @Entity 15 | @Table(name = "Marks") 16 | public class Mark { 17 | 18 | @EmbeddedId 19 | private MarkId markId; 20 | 21 | @Column(name = "Mark") 22 | private int mark; 23 | } 24 | -------------------------------------------------------------------------------- /hibernate-dialect-v5/src/test/java/tech/ydb/hibernate/student/entity/MarkId.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.hibernate.student.entity; 2 | 3 | import lombok.Data; 4 | 5 | import javax.persistence.Column; 6 | import javax.persistence.Embeddable; 7 | import java.io.Serializable; 8 | 9 | @Data 10 | @Embeddable 11 | public class MarkId implements Serializable { 12 | 13 | @Column(name = "StudentId") 14 | private int studentId; 15 | 16 | @Column(name = "CourseId") 17 | private int courseId; 18 | } 19 | 20 | -------------------------------------------------------------------------------- /hibernate-dialect-v5/src/test/java/tech/ydb/hibernate/student/entity/Plan.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.hibernate.student.entity; 2 | 3 | import lombok.Getter; 4 | import lombok.Setter; 5 | 6 | import javax.persistence.EmbeddedId; 7 | import javax.persistence.Entity; 8 | import javax.persistence.Table; 9 | 10 | /** 11 | * @author Kirill Kurdyukov 12 | */ 13 | @Getter 14 | @Setter 15 | @Entity 16 | @Table(name = "Plan") 17 | public class Plan { 18 | 19 | @EmbeddedId 20 | private PlanId planId; 21 | } 22 | -------------------------------------------------------------------------------- /hibernate-dialect-v5/src/test/java/tech/ydb/hibernate/student/entity/PlanId.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.hibernate.student.entity; 2 | 3 | import lombok.Data; 4 | 5 | import javax.persistence.Column; 6 | import javax.persistence.Embeddable; 7 | import java.io.Serializable; 8 | 9 | /** 10 | * @author Kirill Kurdyukov 11 | */ 12 | @Data 13 | @Embeddable 14 | public class PlanId implements Serializable { 15 | 16 | @Column(name = "GroupId") 17 | private int groupId; 18 | 19 | @Column(name = "CourseId") 20 | private int courseId; 21 | 22 | @Column(name = "LecturerId") 23 | private int lecturerId; 24 | } 25 | -------------------------------------------------------------------------------- /hibernate-dialect-v5/src/test/java/tech/ydb/hibernate/student/entity/Student.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.hibernate.student.entity; 2 | 3 | import lombok.Data; 4 | 5 | import javax.persistence.Column; 6 | import javax.persistence.Entity; 7 | import javax.persistence.FetchType; 8 | import javax.persistence.Id; 9 | import javax.persistence.JoinColumn; 10 | import javax.persistence.ManyToMany; 11 | import javax.persistence.ManyToOne; 12 | import javax.persistence.Table; 13 | import java.util.List; 14 | 15 | /** 16 | * @author Kirill Kurdyukov 17 | */ 18 | @Data 19 | @Entity 20 | @Table(name = "Students") 21 | public class Student { 22 | 23 | @Id 24 | @Column(name = "StudentId") 25 | private int id; 26 | 27 | @Column(name = "StudentName") 28 | private String name; 29 | 30 | @ManyToOne(fetch = FetchType.LAZY) 31 | @JoinColumn(name = "GroupId") 32 | private Group group; 33 | 34 | @ManyToMany(mappedBy = "students") 35 | private List courses; 36 | } 37 | -------------------------------------------------------------------------------- /hibernate-dialect-v5/src/test/java/tech/ydb/hibernate/user/User.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.hibernate.user; 2 | 3 | import lombok.Data; 4 | import org.hibernate.annotations.CreationTimestamp; 5 | import org.hibernate.annotations.UpdateTimestamp; 6 | 7 | import javax.persistence.Column; 8 | import javax.persistence.Entity; 9 | import javax.persistence.Id; 10 | import javax.persistence.Table; 11 | import java.time.Instant; 12 | 13 | /** 14 | * @author Kirill Kurdyukov 15 | */ 16 | @Data 17 | @Entity 18 | @Table(name = "`backup/Users`") 19 | public class User { 20 | 21 | @Id 22 | private int id; 23 | 24 | @Column(name = "created_at") 25 | @CreationTimestamp 26 | private Instant createdAt; 27 | 28 | @Column(name = "updated_at") 29 | @UpdateTimestamp 30 | private Instant updatedAt; 31 | 32 | @Column(name = "name") 33 | private String name; 34 | } 35 | -------------------------------------------------------------------------------- /hibernate-dialect-v5/src/test/resources/import-university.sql: -------------------------------------------------------------------------------- 1 | insert into Students (StudentId, StudentName, GroupId) values (1, 'Иванов И.И.', 1), (2, 'Петров П.П.', 1), (3, 'Петров П.П.', 2), (4, 'Сидоров С.С.', 2), (5, 'Неизвестный Н.Н.', 3), (6, 'Безымянный Б.Б', 4); 2 | 3 | insert into Groups (GroupId, GroupName) values (1, 'M3435'), (2, 'M3439'), (3, 'M3238'), (4, 'M3239'); 4 | 5 | insert into Courses (CourseId, CourseName) values (1, 'Базы данных'), (2, 'Управление проектами'), (3, 'ППО'), (4, 'Теория информации'), (6, 'Математический анализ'), (7, 'Технологии Java'); 6 | 7 | insert into Lecturers (LecturerId, LecturerName) values (1, 'Корнеев Г.А.'), (2, 'Будин Н.А.'), (3, 'Кузнецова Е.М.'), (4, 'Киракозов А.Х.'), (6, 'Трофимюк Г.А.'), (7, 'Беляев Е.А.'), (8, 'Кохась К.П.'); 8 | 9 | insert into Plan (GroupId, CourseId, LecturerId) values (1, 1, 2), (2, 1, 1), (1, 2, 3), (1, 3, 4), (2, 3, 4), (2, 4, 6), (1, 4, 7), (2, 4, 7), (4, 6, 8), (1, 7, 1), (2, 7, 1), (3, 7, 1), (4, 7, 1); 10 | 11 | insert into Marks (StudentId, CourseId, Mark) values (1, 1, 5), (2, 1, 4), (3, 1, 3), (2, 2, 3), (3, 2, 4), (4, 2, 5), (7, 1, 5), (8, 1, 5), (7, 7, 5), (8, 7, 5), (5, 7, 5), (6, 7, 5), (3, 3, 3); -------------------------------------------------------------------------------- /hibernate-dialect-v5/src/test/resources/log4j2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /hibernate-dialect/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 1.4.1 ## 2 | 3 | - Deleted `InExpressionCountLimit` 4 | 5 | ## 1.4.0 ## 6 | 7 | - Added hint for YQL pragma queries 8 | 9 | ## 1.3.0 ## 10 | 11 | - Added support UUID YDB type 12 | 13 | ## 1.2.0 ## 14 | 15 | - Added custom decimal jdbc codes `DECIMAL_31_9`, `DECIMAL_35_0`, `DECIMAL_35_9` 16 | 17 | ## 1.1.0 ## 18 | 19 | - Added hint for scan queries 20 | 21 | ## 1.0.0 ## 22 | 23 | - Fixed: data time type converters 24 | 25 | ## 0.9.5 ## 26 | 27 | - Added query hint for view index for "select * from ... where" queries 28 | 29 | ## 0.9.4 ## 30 | 31 | - Fixed the generated bool value 32 | 33 | ## 0.9.3 ## 34 | 35 | - Supported enum field of Entity 36 | 37 | ## 0.9.2 ## 38 | 39 | - Supported LocalDateTime with datetime YDB primitive type and mapped to java.sql.Types.TIME 40 | 41 | ## 0.9.1 ## 42 | 43 | - Full CRUD operations 44 | - Support LIKE / ILIKE statement with ESCAPE 45 | - Support LIMIT ? OFFSET ? statement 46 | - Support ORDER BY ? statement 47 | - @OneToOne, @ManyToMany, @OneToMany, @ManyToOne 48 | - Generate table schema -------------------------------------------------------------------------------- /hibernate-dialect/src/main/java/tech/ydb/hibernate/dialect/exporter/EmptyExporter.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.hibernate.dialect.exporter; 2 | 3 | import org.hibernate.boot.Metadata; 4 | import org.hibernate.boot.model.relational.Exportable; 5 | import org.hibernate.boot.model.relational.SqlStringGenerationContext; 6 | import org.hibernate.tool.schema.spi.Exporter; 7 | 8 | /** 9 | * @author Kirill Kurdyukov 10 | */ 11 | public class EmptyExporter implements Exporter { 12 | 13 | @Override 14 | public String[] getSqlCreateStrings(T exportable, Metadata metadata, SqlStringGenerationContext context) { 15 | return NO_COMMANDS; 16 | } 17 | 18 | @Override 19 | public String[] getSqlDropStrings(T exportable, Metadata metadata, SqlStringGenerationContext context) { 20 | return NO_COMMANDS; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /hibernate-dialect/src/main/java/tech/ydb/hibernate/dialect/hint/PragmaQueryHintHandler.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.hibernate.dialect.hint; 2 | 3 | import java.util.List; 4 | import java.util.stream.Collectors; 5 | 6 | /** 7 | * @author Kirill Kurdyukov 8 | */ 9 | public class PragmaQueryHintHandler implements QueryHintHandler { 10 | public static final PragmaQueryHintHandler INSTANCE = new PragmaQueryHintHandler(); 11 | 12 | private static final String HINT_PRAGMA = "add_pragma:"; 13 | 14 | @Override 15 | public String addQueryHints(String query, List hints) { 16 | var yqlHints = hints.stream() 17 | .filter(hint -> hint.startsWith(HINT_PRAGMA)) 18 | .map(hint -> "PRAGMA " + hint.substring(HINT_PRAGMA.length()) + ";\n") 19 | .collect(Collectors.joining()); 20 | 21 | return yqlHints + query; 22 | } 23 | 24 | @Override 25 | public boolean commentIsHint(String comment) { 26 | return comment.startsWith(HINT_PRAGMA); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /hibernate-dialect/src/main/java/tech/ydb/hibernate/dialect/hint/QueryHintHandler.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.hibernate.dialect.hint; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * @author Kirill Kurdyukov 7 | */ 8 | public interface QueryHintHandler { 9 | 10 | String addQueryHints(String query, List hints); 11 | 12 | boolean commentIsHint(String comment); 13 | } 14 | -------------------------------------------------------------------------------- /hibernate-dialect/src/main/java/tech/ydb/hibernate/dialect/hint/ScanQueryHintHandler.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.hibernate.dialect.hint; 2 | 3 | import java.util.List; 4 | import java.util.concurrent.atomic.AtomicBoolean; 5 | 6 | /** 7 | * @author Kirill Kurdyukov 8 | */ 9 | public class ScanQueryHintHandler implements QueryHintHandler { 10 | public static final ScanQueryHintHandler INSTANCE = new ScanQueryHintHandler(); 11 | 12 | private static final String HINT_USE_SCAN = "use_scan"; 13 | 14 | private ScanQueryHintHandler() { 15 | 16 | } 17 | 18 | @Override 19 | public String addQueryHints(String query, List hints) { 20 | AtomicBoolean useScan = new AtomicBoolean(false); 21 | hints.forEach(hint -> { 22 | if (hint.equals(HINT_USE_SCAN)) { 23 | useScan.set(true); 24 | } 25 | }); 26 | 27 | if (useScan.get()) { 28 | return "scan " + query; 29 | } 30 | 31 | return query; 32 | } 33 | 34 | @Override 35 | public boolean commentIsHint(String comment) { 36 | return comment.startsWith(HINT_USE_SCAN); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /hibernate-dialect/src/main/java/tech/ydb/hibernate/dialect/translator/YdbSqlAstTranslatorFactory.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.hibernate.dialect.translator; 2 | 3 | import org.hibernate.engine.spi.SessionFactoryImplementor; 4 | import org.hibernate.sql.ast.SqlAstTranslator; 5 | import org.hibernate.sql.ast.spi.StandardSqlAstTranslatorFactory; 6 | import org.hibernate.sql.ast.tree.Statement; 7 | import org.hibernate.sql.exec.spi.JdbcOperation; 8 | 9 | /** 10 | * @author Kirill Kurdyukov 11 | */ 12 | public class YdbSqlAstTranslatorFactory extends StandardSqlAstTranslatorFactory { 13 | 14 | public static final YdbSqlAstTranslatorFactory YDB_SQL_AST_TRANSLATOR_FACTORY = new YdbSqlAstTranslatorFactory(); 15 | 16 | @Override 17 | protected SqlAstTranslator buildTranslator( 18 | SessionFactoryImplementor sessionFactory, 19 | Statement statement 20 | ) { 21 | return new YdbSqlAstTranslator<>(sessionFactory, statement); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /hibernate-dialect/src/main/java/tech/ydb/hibernate/dialect/types/BigDecimalJavaType.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.hibernate.dialect.types; 2 | 3 | import org.hibernate.dialect.Dialect; 4 | import org.hibernate.type.descriptor.jdbc.JdbcType; 5 | 6 | /** 7 | * @author Kirill Kurdyukov 8 | */ 9 | public final class BigDecimalJavaType extends org.hibernate.type.descriptor.java.BigDecimalJavaType { 10 | 11 | public static final BigDecimalJavaType INSTANCE_22_9 = new BigDecimalJavaType(); 12 | 13 | @Override 14 | public int getDefaultSqlScale(Dialect dialect, JdbcType jdbcType) { 15 | return 9; 16 | } 17 | 18 | @Override 19 | public int getDefaultSqlPrecision(Dialect dialect, JdbcType jdbcType) { 20 | return 22; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /hibernate-dialect/src/main/java/tech/ydb/hibernate/dialect/types/InstantJavaType.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.hibernate.dialect.types; 2 | 3 | import org.hibernate.type.descriptor.jdbc.JdbcType; 4 | import org.hibernate.type.descriptor.jdbc.JdbcTypeIndicators; 5 | 6 | /** 7 | * @author Kirill Kurdyukov 8 | */ 9 | public class InstantJavaType extends org.hibernate.type.descriptor.java.InstantJavaType { 10 | 11 | public static final InstantJavaType INSTANCE = new InstantJavaType(); 12 | 13 | @Override 14 | public JdbcType getRecommendedJdbcType(JdbcTypeIndicators context) { 15 | return InstantJdbcType.INSTANCE; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /hibernate-dialect/src/main/java/tech/ydb/hibernate/dialect/types/LocalDateJavaType.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.hibernate.dialect.types; 2 | 3 | import org.hibernate.type.descriptor.jdbc.JdbcType; 4 | import org.hibernate.type.descriptor.jdbc.JdbcTypeIndicators; 5 | 6 | /** 7 | * @author Kirill Kurdyukov 8 | */ 9 | public class LocalDateJavaType extends org.hibernate.type.descriptor.java.LocalDateJavaType { 10 | 11 | public static final LocalDateJavaType INSTANCE = new LocalDateJavaType(); 12 | 13 | @Override 14 | public JdbcType getRecommendedJdbcType(JdbcTypeIndicators context) { 15 | return LocalDateJdbcType.INSTANCE; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /hibernate-dialect/src/main/java/tech/ydb/hibernate/dialect/types/LocalDateTimeJavaType.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.hibernate.dialect.types; 2 | 3 | import org.hibernate.type.descriptor.jdbc.JdbcType; 4 | import org.hibernate.type.descriptor.jdbc.JdbcTypeIndicators; 5 | 6 | /** 7 | * @author Kirill Kurdyukov 8 | */ 9 | public class LocalDateTimeJavaType extends org.hibernate.type.descriptor.java.LocalDateTimeJavaType { 10 | 11 | public static final LocalDateTimeJavaType INSTANCE = new LocalDateTimeJavaType(); 12 | 13 | @Override 14 | public JdbcType getRecommendedJdbcType(JdbcTypeIndicators context) { 15 | return LocalDateTimeJdbcType.INSTANCE; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /hibernate-dialect/src/test/java/tech/ydb/hibernate/auto_inc/TestEntityFail.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.hibernate.auto_inc; 2 | 3 | import jakarta.persistence.Column; 4 | import jakarta.persistence.Entity; 5 | import jakarta.persistence.GeneratedValue; 6 | import jakarta.persistence.GenerationType; 7 | import jakarta.persistence.Id; 8 | import jakarta.persistence.Table; 9 | import lombok.AllArgsConstructor; 10 | import lombok.Data; 11 | import lombok.NoArgsConstructor; 12 | 13 | /** 14 | * @author Kirill Kurdyukov 15 | */ 16 | @Entity 17 | @Data 18 | @AllArgsConstructor 19 | @NoArgsConstructor 20 | @Table(name = "test_table_int_auto_fail") 21 | public class TestEntityFail { 22 | 23 | @Id 24 | @GeneratedValue(strategy = GenerationType.IDENTITY) 25 | private String id; 26 | 27 | @Column 28 | private String text; 29 | } 30 | -------------------------------------------------------------------------------- /hibernate-dialect/src/test/java/tech/ydb/hibernate/auto_inc/TestEntityInt.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.hibernate.auto_inc; 2 | 3 | import jakarta.persistence.Column; 4 | import jakarta.persistence.Entity; 5 | import jakarta.persistence.GeneratedValue; 6 | import jakarta.persistence.GenerationType; 7 | import jakarta.persistence.Id; 8 | import jakarta.persistence.Table; 9 | import lombok.AllArgsConstructor; 10 | import lombok.Data; 11 | import lombok.NoArgsConstructor; 12 | 13 | /** 14 | * @author Kirill Kurdyukov 15 | */ 16 | @Entity 17 | @Data 18 | @AllArgsConstructor 19 | @NoArgsConstructor 20 | @Table(name = "test_table_int_auto_inc") 21 | public class TestEntityInt { 22 | 23 | @Id 24 | @GeneratedValue(strategy = GenerationType.IDENTITY) 25 | private int id; 26 | 27 | @Column 28 | private String text; 29 | } 30 | -------------------------------------------------------------------------------- /hibernate-dialect/src/test/java/tech/ydb/hibernate/auto_inc/TestEntityLong.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.hibernate.auto_inc; 2 | 3 | import jakarta.persistence.Column; 4 | import jakarta.persistence.Entity; 5 | import jakarta.persistence.GeneratedValue; 6 | import jakarta.persistence.GenerationType; 7 | import jakarta.persistence.Id; 8 | import jakarta.persistence.Table; 9 | import lombok.AllArgsConstructor; 10 | import lombok.Data; 11 | import lombok.NoArgsConstructor; 12 | 13 | /** 14 | * @author Kirill Kurdyukov 15 | */ 16 | @Entity 17 | @Data 18 | @AllArgsConstructor 19 | @NoArgsConstructor 20 | @Table(name = "test_table_int_auto_long") 21 | public class TestEntityLong { 22 | 23 | @Id 24 | @GeneratedValue(strategy = GenerationType.IDENTITY) 25 | private long id; 26 | 27 | @Column 28 | private String text; 29 | } 30 | -------------------------------------------------------------------------------- /hibernate-dialect/src/test/java/tech/ydb/hibernate/auto_inc/TestEntityShort.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.hibernate.auto_inc; 2 | 3 | import jakarta.persistence.Column; 4 | import jakarta.persistence.Entity; 5 | import jakarta.persistence.GeneratedValue; 6 | import jakarta.persistence.GenerationType; 7 | import jakarta.persistence.Id; 8 | import jakarta.persistence.Table; 9 | import lombok.AllArgsConstructor; 10 | import lombok.Data; 11 | import lombok.NoArgsConstructor; 12 | 13 | /** 14 | * @author Kirill Kurdyukov 15 | */ 16 | @Entity 17 | @Data 18 | @AllArgsConstructor 19 | @NoArgsConstructor 20 | @Table(name = "test_table_int_auto_short") 21 | public class TestEntityShort { 22 | 23 | @Id 24 | @GeneratedValue(strategy = GenerationType.IDENTITY) 25 | private short id; 26 | 27 | @Column 28 | private String text; 29 | } 30 | -------------------------------------------------------------------------------- /hibernate-dialect/src/test/java/tech/ydb/hibernate/datetime/TestEntity.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.hibernate.datetime; 2 | 3 | import jakarta.persistence.Column; 4 | import jakarta.persistence.Entity; 5 | import jakarta.persistence.Id; 6 | import jakarta.persistence.Table; 7 | import java.time.Instant; 8 | import java.time.LocalDate; 9 | import java.time.LocalDateTime; 10 | import lombok.Data; 11 | 12 | /** 13 | * @author Kirill Kurdyukov 14 | */ 15 | @Entity 16 | @Data 17 | @Table(name = "hibernate_test") 18 | public class TestEntity { 19 | 20 | @Id 21 | private Integer id; 22 | 23 | @Column(name = "c_Date", nullable = false) 24 | private LocalDate date; 25 | 26 | @Column(name = "c_Datetime", nullable = false) 27 | private LocalDateTime datetime; 28 | 29 | @Column(name = "c_Timestamp", nullable = false) 30 | private Instant timestamp; 31 | } 32 | -------------------------------------------------------------------------------- /hibernate-dialect/src/test/java/tech/ydb/hibernate/student/entity/Group.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.hibernate.student.entity; 2 | 3 | import jakarta.persistence.Column; 4 | import jakarta.persistence.Entity; 5 | import jakarta.persistence.Id; 6 | import jakarta.persistence.Index; 7 | import jakarta.persistence.NamedQuery; 8 | import jakarta.persistence.OneToMany; 9 | import jakarta.persistence.Table; 10 | import java.util.List; 11 | import lombok.Getter; 12 | import lombok.Setter; 13 | 14 | /** 15 | * @author Kirill Kurdyukov 16 | */ 17 | @Getter 18 | @Setter 19 | @Entity 20 | @Table(name = "Groups", indexes = @Index(name = "group_name_index", columnList = "GroupName")) 21 | @NamedQuery( 22 | name = "Group.findGroups", 23 | query = "SELECT g FROM Group g " + 24 | "JOIN Plan p ON g.id = p.planId.groupId " + 25 | "JOIN Lecturer l ON p.planId.lecturerId = l.id " + 26 | "WHERE p.planId.courseId = :CourseId and l.id = :LecturerId" 27 | ) 28 | public class Group { 29 | 30 | @Id 31 | @Column(name = "GroupId") 32 | private int id; 33 | 34 | @Column(name = "GroupName") 35 | private String name; 36 | 37 | @OneToMany(mappedBy = "group") 38 | private List students; 39 | 40 | @Override 41 | public int hashCode() { 42 | return id; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /hibernate-dialect/src/test/java/tech/ydb/hibernate/student/entity/Lecturer.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.hibernate.student.entity; 2 | 3 | import jakarta.persistence.Column; 4 | import jakarta.persistence.Entity; 5 | import jakarta.persistence.Id; 6 | import jakarta.persistence.Table; 7 | import lombok.Getter; 8 | import lombok.Setter; 9 | 10 | /** 11 | * @author Kirill Kurdyukov 12 | */ 13 | @Getter 14 | @Setter 15 | @Entity 16 | @Table(name = "Lecturers") 17 | public class Lecturer { 18 | 19 | @Id 20 | @Column(name = "LecturerId") 21 | private int id; 22 | 23 | @Column(name = "LecturerName") 24 | private String name; 25 | } 26 | -------------------------------------------------------------------------------- /hibernate-dialect/src/test/java/tech/ydb/hibernate/student/entity/Mark.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.hibernate.student.entity; 2 | 3 | import jakarta.persistence.Column; 4 | import jakarta.persistence.EmbeddedId; 5 | import jakarta.persistence.Entity; 6 | import jakarta.persistence.Table; 7 | import lombok.Data; 8 | 9 | /** 10 | * @author Kirill Kurdyukov 11 | */ 12 | @Data 13 | @Entity 14 | @Table(name = "Marks") 15 | public class Mark { 16 | 17 | @EmbeddedId 18 | private MarkId markId; 19 | 20 | @Column(name = "Mark") 21 | private int mark; 22 | } 23 | -------------------------------------------------------------------------------- /hibernate-dialect/src/test/java/tech/ydb/hibernate/student/entity/MarkId.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.hibernate.student.entity; 2 | 3 | import jakarta.persistence.Column; 4 | import jakarta.persistence.Embeddable; 5 | import lombok.Data; 6 | 7 | import java.io.Serializable; 8 | 9 | @Data 10 | @Embeddable 11 | public class MarkId implements Serializable { 12 | 13 | @Column(name = "StudentId") 14 | private int studentId; 15 | 16 | @Column(name = "CourseId") 17 | private int courseId; 18 | } 19 | 20 | -------------------------------------------------------------------------------- /hibernate-dialect/src/test/java/tech/ydb/hibernate/student/entity/Plan.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.hibernate.student.entity; 2 | 3 | import jakarta.persistence.EmbeddedId; 4 | import jakarta.persistence.Entity; 5 | import jakarta.persistence.Table; 6 | import lombok.Getter; 7 | import lombok.Setter; 8 | 9 | /** 10 | * @author Kirill Kurdyukov 11 | */ 12 | @Getter 13 | @Setter 14 | @Entity 15 | @Table(name = "Plan") 16 | public class Plan { 17 | 18 | @EmbeddedId 19 | private PlanId planId; 20 | } 21 | -------------------------------------------------------------------------------- /hibernate-dialect/src/test/java/tech/ydb/hibernate/student/entity/PlanId.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.hibernate.student.entity; 2 | 3 | import jakarta.persistence.Column; 4 | import jakarta.persistence.Embeddable; 5 | import lombok.Data; 6 | 7 | import java.io.Serializable; 8 | 9 | /** 10 | * @author Kirill Kurdyukov 11 | */ 12 | @Data 13 | @Embeddable 14 | public class PlanId implements Serializable { 15 | 16 | @Column(name = "GroupId") 17 | private int groupId; 18 | 19 | @Column(name = "CourseId") 20 | private int courseId; 21 | 22 | @Column(name = "LecturerId") 23 | private int lecturerId; 24 | } 25 | -------------------------------------------------------------------------------- /hibernate-dialect/src/test/java/tech/ydb/hibernate/student/entity/Student.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.hibernate.student.entity; 2 | 3 | import jakarta.persistence.Column; 4 | import jakarta.persistence.Entity; 5 | import jakarta.persistence.FetchType; 6 | import jakarta.persistence.Id; 7 | import jakarta.persistence.JoinColumn; 8 | import jakarta.persistence.ManyToMany; 9 | import jakarta.persistence.ManyToOne; 10 | import jakarta.persistence.Table; 11 | import lombok.Data; 12 | 13 | import java.util.List; 14 | 15 | /** 16 | * @author Kirill Kurdyukov 17 | */ 18 | @Data 19 | @Entity 20 | @Table(name = "Students") 21 | public class Student { 22 | 23 | @Id 24 | @Column(name = "StudentId") 25 | private int id; 26 | 27 | @Column(name = "StudentName") 28 | private String name; 29 | 30 | @ManyToOne(fetch = FetchType.LAZY) 31 | @JoinColumn(name = "GroupId") 32 | private Group group; 33 | 34 | @ManyToMany(mappedBy = "students") 35 | private List courses; 36 | } 37 | -------------------------------------------------------------------------------- /hibernate-dialect/src/test/java/tech/ydb/hibernate/ydb_jdbc_code/TestEntity.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.hibernate.ydb_jdbc_code; 2 | 3 | import jakarta.persistence.Column; 4 | import jakarta.persistence.Entity; 5 | import jakarta.persistence.Id; 6 | import jakarta.persistence.Table; 7 | import java.math.BigDecimal; 8 | import lombok.AllArgsConstructor; 9 | import lombok.Data; 10 | import lombok.NoArgsConstructor; 11 | import org.hibernate.annotations.JdbcTypeCode; 12 | import tech.ydb.hibernate.dialect.code.YdbJdbcCode; 13 | 14 | /** 15 | * @author Kirill Kurdyukov 16 | */ 17 | @Entity 18 | @Data 19 | @AllArgsConstructor 20 | @NoArgsConstructor 21 | @Table(name = "hibernate_test_bigdecimal") 22 | public class TestEntity { 23 | 24 | @Id 25 | @JdbcTypeCode(YdbJdbcCode.UINT8) 26 | private int id; 27 | 28 | @Column 29 | private BigDecimal default_bigDecimal; 30 | 31 | @Column 32 | @JdbcTypeCode(YdbJdbcCode.DECIMAL_31_9) 33 | private BigDecimal bigDecimal31_9; 34 | 35 | @Column 36 | @JdbcTypeCode(YdbJdbcCode.DECIMAL_35_0) 37 | private BigDecimal bigDecimal35_0; 38 | 39 | @Column 40 | @JdbcTypeCode(YdbJdbcCode.DECIMAL_35_9) 41 | private BigDecimal bigDecimal35_9; 42 | } 43 | -------------------------------------------------------------------------------- /hibernate-dialect/src/test/resources/import-university.sql: -------------------------------------------------------------------------------- 1 | insert into Students (StudentId, StudentName, GroupId) values (1, 'Иванов И.И.', 1), (2, 'Петров П.П.', 1), (3, 'Петров П.П.', 2), (4, 'Сидоров С.С.', 2), (5, 'Неизвестный Н.Н.', 3), (6, 'Безымянный Б.Б', 4); 2 | 3 | insert into Groups (GroupId, GroupName) values (1, 'M3435'), (2, 'M3439'), (3, 'M3238'), (4, 'M3239'); 4 | 5 | insert into Courses (CourseId, CourseName) values (1, 'Базы данных'), (2, 'Управление проектами'), (3, 'ППО'), (4, 'Теория информации'), (6, 'Математический анализ'), (7, 'Технологии Java'); 6 | 7 | insert into Lecturers (LecturerId, LecturerName) values (1, 'Корнеев Г.А.'), (2, 'Будин Н.А.'), (3, 'Кузнецова Е.М.'), (4, 'Киракозов А.Х.'), (6, 'Трофимюк Г.А.'), (7, 'Беляев Е.А.'), (8, 'Кохась К.П.'); 8 | 9 | insert into Plan (GroupId, CourseId, LecturerId) values (1, 1, 2), (2, 1, 1), (1, 2, 3), (1, 3, 4), (2, 3, 4), (2, 4, 6), (1, 4, 7), (2, 4, 7), (4, 6, 8), (1, 7, 1), (2, 7, 1), (3, 7, 1), (4, 7, 1); 10 | 11 | insert into Marks (StudentId, CourseId, Mark) values (1, 1, 5), (2, 1, 4), (3, 1, 3), (2, 2, 3), (3, 2, 4), (4, 2, 5), (7, 1, 5), (8, 1, 5), (7, 7, 5), (8, 7, 5), (5, 7, 5), (6, 7, 5), (3, 3, 3); -------------------------------------------------------------------------------- /hibernate-dialect/src/test/resources/log4j2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /jooq-dialect/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 1.1.1 ## 2 | 3 | - Supported UUID YDB Type 4 | 5 | ## 1.1.0 ## 6 | - Upgrade to new version of JDBC & SDK 7 | 8 | ## 1.0.1 ## 9 | - Fixed bug with `useIndex` - skip the table name (`from view`) 10 | 11 | ## 1.0.0 ## 12 | 13 | - `REPLACE` / `UPSERT` builders from YDB 14 | - Supported VIEW INDEX from `useIndex("index_name")` HintedTable 15 | - Generated tables from schema 16 | -------------------------------------------------------------------------------- /jooq-dialect/src/main/java/org/jooq/impl/AbstractYdbAggregateFunction.java: -------------------------------------------------------------------------------- 1 | package org.jooq.impl; 2 | 3 | import org.jooq.DataType; 4 | import org.jooq.Field; 5 | import org.jooq.Name; 6 | 7 | public abstract class AbstractYdbAggregateFunction extends AbstractAggregateFunction { 8 | protected AbstractYdbAggregateFunction(String name, DataType type, Field... arguments) { 9 | super(name, type, arguments); 10 | } 11 | 12 | protected AbstractYdbAggregateFunction(Name name, DataType type, Field... arguments) { 13 | super(name, type, arguments); 14 | } 15 | 16 | protected AbstractYdbAggregateFunction(boolean distinct, String name, DataType type, Field... arguments) { 17 | super(distinct, name, type, arguments); 18 | } 19 | 20 | protected AbstractYdbAggregateFunction(boolean distinct, Name name, DataType type, Field... arguments) { 21 | super(distinct, name, type, arguments); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /jooq-dialect/src/main/java/org/jooq/impl/AbstractYdbCondition.java: -------------------------------------------------------------------------------- 1 | package org.jooq.impl; 2 | 3 | public abstract class AbstractYdbCondition extends AbstractCondition { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /jooq-dialect/src/main/java/org/jooq/impl/AbstractYdbFunction.java: -------------------------------------------------------------------------------- 1 | package org.jooq.impl; 2 | 3 | import org.jooq.Binding; 4 | import org.jooq.Comment; 5 | import org.jooq.Context; 6 | import org.jooq.DataType; 7 | import org.jooq.Name; 8 | 9 | public abstract class AbstractYdbFunction extends AbstractField { 10 | protected AbstractYdbFunction(Name name, DataType type) { 11 | super(name, type); 12 | } 13 | 14 | protected AbstractYdbFunction(Name name, DataType type, Comment comment, Binding binding) { 15 | super(name, type, comment, binding); 16 | } 17 | 18 | @Override 19 | protected boolean parenthesised(Context ctx) { 20 | return true; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /jooq-dialect/src/main/java/org/jooq/impl/ConnectionUtils.java: -------------------------------------------------------------------------------- 1 | package org.jooq.impl; 2 | 3 | import io.r2dbc.spi.ConnectionFactory; 4 | import org.jooq.ConnectionProvider; 5 | import org.jooq.tools.jdbc.JDBCUtils; 6 | 7 | import java.sql.Connection; 8 | 9 | public final class ConnectionUtils { 10 | private ConnectionUtils() { 11 | throw new UnsupportedOperationException(); 12 | } 13 | 14 | public static ConnectionProvider closeableProvider(Connection connection) { 15 | return new DefaultCloseableConnectionProvider(connection); 16 | } 17 | 18 | public static void closeConnectionProvider(ConnectionProvider connectionProvider) { 19 | if (connectionProvider instanceof DefaultCloseableConnectionProvider dcp) { 20 | JDBCUtils.safeClose(dcp.connection); 21 | dcp.connection = null; 22 | } 23 | } 24 | 25 | public static void closeConnectionFactory(ConnectionFactory connectionFactory) { 26 | if (connectionFactory instanceof DefaultConnectionFactory dcf) { 27 | if (dcf.finalize) { 28 | R2DBC.blockWrappingExceptions(dcf.connection.close()); 29 | dcf.connection = null; 30 | } 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /jooq-dialect/src/main/java/org/jooq/impl/YdbTools.java: -------------------------------------------------------------------------------- 1 | package org.jooq.impl; 2 | 3 | import org.jooq.*; 4 | import tech.ydb.jooq.YDB; 5 | 6 | public final class YdbTools { 7 | 8 | private YdbTools() { 9 | throw new UnsupportedOperationException(); 10 | } 11 | 12 | @SuppressWarnings("unchecked") 13 | public static Field[] combineTyped(Field field, Field... fields) { 14 | if (fields == null) { 15 | return new Field[]{field}; 16 | } else { 17 | Field[] result = new Field[fields.length + 1]; 18 | result[0] = field; 19 | System.arraycopy(fields, 0, result, 1, fields.length); 20 | 21 | return result; 22 | } 23 | } 24 | 25 | @SuppressWarnings("unchecked") 26 | public static Field[] combine(Field field, Field... fields) { 27 | return combineTyped((Field) field, (Field[]) fields); 28 | } 29 | 30 | @SuppressWarnings("unchecked") 31 | public static Field[] fieldsArray(T[] values) { 32 | Field[] result = new Field[values.length]; 33 | 34 | for (int i = 0; i < values.length; i++) { 35 | result[i] = YDB.val(values[i]); 36 | } 37 | 38 | return result; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /jooq-dialect/src/main/java/tech/ydb/jooq/CloseableYdbDSLContext.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.jooq; 2 | 3 | import org.jooq.exception.DataAccessException; 4 | import org.jooq.impl.DSL; 5 | 6 | import java.sql.Connection; 7 | import java.util.Properties; 8 | 9 | /** 10 | * A resourceful {@link YdbDSLContext} that should be closed in a 11 | * try-with-resources statement. 12 | */ 13 | public interface CloseableYdbDSLContext extends YdbDSLContext, AutoCloseable { 14 | /** 15 | * Close the underlying resources, if any resources have been allocated when 16 | * constructing this YdbDslContext. 17 | *

18 | * Some {@link YdbDSLContext} constructors, such as {@link DSL#using(String)}, 19 | * {@link DSL#using(String, Properties)}, or 20 | * {@link DSL#using(String, String, String)} allocate a {@link Connection} 21 | * resource, which is inaccessible to the outside of the {@link YdbDSLContext} 22 | * implementation. Proper resource management must thus be done via this 23 | * {@link #close()} method. 24 | * 25 | * @throws DataAccessException When something went wrong closing the 26 | * underlying resources. 27 | */ 28 | @Override 29 | void close() throws DataAccessException; 30 | } 31 | -------------------------------------------------------------------------------- /jooq-dialect/src/main/java/tech/ydb/jooq/Replace.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.jooq; 2 | 3 | import org.jooq.DMLQuery; 4 | import org.jooq.Record; 5 | import org.jooq.Table; 6 | 7 | /** 8 | * An REPLACE statement. 9 | *

10 | * Example: 11 | *


12 |  * // Assuming import static org.jooq.impl.DSL.* and tech.ydb.jooq.*;
13 |  *
14 |  * using(configuration)
15 |  *    .replaceInto(ACTOR)
16 |  *    .columns(ACTOR.FIRST_NAME, ACTOR.LAST_NAME)
17 |  *    .values("John", "Doe")
18 |  *    .execute();
19 |  * 
20 | *

21 | * Instances can be created using {@link YDB#replaceInto(Table)}, or 22 | * {@link YdbDSLContext#replaceQuery(Table)} and overloads. 23 | * 24 | * @param the record type that is being manipulated by the REPLACE statement 25 | */ 26 | public interface Replace extends DMLQuery { 27 | 28 | } 29 | -------------------------------------------------------------------------------- /jooq-dialect/src/main/java/tech/ydb/jooq/Upsert.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.jooq; 2 | 3 | import org.jooq.DMLQuery; 4 | import org.jooq.Record; 5 | import org.jooq.Table; 6 | 7 | /** 8 | * An UPSERT statement. 9 | *

10 | * Example: 11 | *


12 |  * // Assuming import static org.jooq.impl.DSL.* and tech.ydb.jooq.*;
13 |  *
14 |  * using(configuration)
15 |  *    .upsertInto(ACTOR)
16 |  *    .columns(ACTOR.FIRST_NAME, ACTOR.LAST_NAME)
17 |  *    .values("John", "Doe")
18 |  *    .execute();
19 |  * 
20 | *

21 | * Instances can be created using {@link YDB#upsertInto(Table)}, or 22 | * {@link YdbDSLContext#upsertQuery(Table)} and overloads. 23 | * 24 | * @param the record type that is being manipulated by the UPSERT statement 25 | */ 26 | public interface Upsert extends DMLQuery { 27 | 28 | } 29 | -------------------------------------------------------------------------------- /jooq-dialect/src/main/java/tech/ydb/jooq/YdbKeywords.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.jooq; 2 | 3 | import org.jooq.Keyword; 4 | 5 | import static org.jooq.impl.DSL.keyword; 6 | 7 | public final class YdbKeywords { 8 | private YdbKeywords() { 9 | throw new UnsupportedOperationException(); 10 | } 11 | 12 | public static final Keyword K_UPSERT = keyword("upsert"); 13 | public static final Keyword K_REPLACE = keyword("replace"); 14 | } 15 | -------------------------------------------------------------------------------- /jooq-dialect/src/main/java/tech/ydb/jooq/binding/BindingTools.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.jooq.binding; 2 | 3 | import tech.ydb.jdbc.YdbConst; 4 | import tech.ydb.table.values.PrimitiveType; 5 | 6 | public final class BindingTools { 7 | private BindingTools() { 8 | } 9 | 10 | public static int indexType(PrimitiveType type) { 11 | return type.ordinal() + YdbConst.SQL_KIND_PRIMITIVE; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /jooq-dialect/src/main/java/tech/ydb/jooq/binding/UuidBinding.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.jooq.binding; 2 | 3 | import java.sql.SQLException; 4 | import java.util.UUID; 5 | import org.jooq.BindingGetResultSetContext; 6 | import org.jooq.BindingSetStatementContext; 7 | import org.jooq.Converter; 8 | import org.jooq.impl.AbstractBinding; 9 | import org.jooq.impl.IdentityConverter; 10 | import static tech.ydb.jooq.binding.BindingTools.indexType; 11 | import tech.ydb.table.values.PrimitiveType; 12 | 13 | /** 14 | * @author Kirill Kurdyukov 15 | */ 16 | public class UuidBinding extends AbstractBinding { 17 | 18 | private static final int INDEX_TYPE = indexType(PrimitiveType.Uuid); 19 | 20 | @Override 21 | public Converter converter() { 22 | return new IdentityConverter<>(UUID.class); 23 | } 24 | 25 | @Override 26 | public void set(BindingSetStatementContext ctx) throws SQLException { 27 | if (ctx.value() == null) { 28 | ctx.statement().setNull(ctx.index(), INDEX_TYPE); 29 | } else { 30 | ctx.statement().setObject(ctx.index(), ctx.value(), INDEX_TYPE); 31 | } 32 | } 33 | 34 | @Override 35 | public void get(BindingGetResultSetContext ctx) throws SQLException { 36 | ctx.value((UUID) ctx.resultSet().getObject(ctx.index())); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /jooq-dialect/src/main/java/tech/ydb/jooq/dsl/function/aggregate/Avg.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.jooq.dsl.function.aggregate; 2 | 3 | import org.jooq.DataType; 4 | import org.jooq.Field; 5 | import org.jooq.Name; 6 | import org.jooq.impl.AbstractYdbAggregateFunction; 7 | 8 | import static org.jooq.impl.DSL.systemName; 9 | 10 | public final class Avg extends AbstractYdbAggregateFunction { 11 | 12 | private static final Name AVG = systemName("Avg"); 13 | 14 | public Avg(Field field, boolean distinct, DataType type) { 15 | super( 16 | distinct, 17 | AVG, 18 | type, 19 | field 20 | ); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /jooq-dialect/src/main/java/tech/ydb/jooq/dsl/function/aggregate/AvgIf.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.jooq.dsl.function.aggregate; 2 | 3 | import org.jooq.Condition; 4 | import org.jooq.Field; 5 | import org.jooq.Name; 6 | import org.jooq.impl.AbstractYdbAggregateFunction; 7 | import tech.ydb.jooq.YdbTypes; 8 | 9 | import static org.jooq.impl.DSL.systemName; 10 | 11 | public final class AvgIf extends AbstractYdbAggregateFunction { 12 | 13 | private static final Name AVG_IF = systemName("avg_if"); 14 | 15 | public AvgIf(Field field, Condition condition, boolean distinct) { 16 | super( 17 | distinct, 18 | AVG_IF, 19 | YdbTypes.DOUBLE, 20 | field, 21 | condition 22 | ); 23 | } 24 | } 25 | 26 | -------------------------------------------------------------------------------- /jooq-dialect/src/main/java/tech/ydb/jooq/dsl/function/aggregate/BitAnd.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.jooq.dsl.function.aggregate; 2 | 3 | import org.jooq.Field; 4 | import org.jooq.Name; 5 | import org.jooq.impl.AbstractYdbAggregateFunction; 6 | 7 | import static org.jooq.impl.DSL.systemName; 8 | 9 | public final class BitAnd extends AbstractYdbAggregateFunction { 10 | 11 | private static final Name BIT_AND = systemName("bit_and"); 12 | 13 | public BitAnd(Field field) { 14 | super( 15 | false, 16 | BIT_AND, 17 | field.getDataType(), 18 | field 19 | ); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /jooq-dialect/src/main/java/tech/ydb/jooq/dsl/function/aggregate/BitOr.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.jooq.dsl.function.aggregate; 2 | 3 | import org.jooq.Field; 4 | import org.jooq.Name; 5 | import org.jooq.impl.AbstractYdbAggregateFunction; 6 | 7 | import static org.jooq.impl.DSL.systemName; 8 | 9 | public final class BitOr extends AbstractYdbAggregateFunction { 10 | 11 | private static final Name BIT_OR = systemName("bit_or"); 12 | 13 | public BitOr(Field field) { 14 | super( 15 | false, 16 | BIT_OR, 17 | field.getDataType(), 18 | field 19 | ); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /jooq-dialect/src/main/java/tech/ydb/jooq/dsl/function/aggregate/BitXor.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.jooq.dsl.function.aggregate; 2 | 3 | import org.jooq.Field; 4 | import org.jooq.Name; 5 | import org.jooq.impl.AbstractYdbAggregateFunction; 6 | 7 | import static org.jooq.impl.DSL.systemName; 8 | 9 | public final class BitXor extends AbstractYdbAggregateFunction { 10 | 11 | private static final Name BIT_XOR = systemName("bit_xor"); 12 | 13 | public BitXor(Field field) { 14 | super( 15 | false, 16 | BIT_XOR, 17 | field.getDataType(), 18 | field 19 | ); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /jooq-dialect/src/main/java/tech/ydb/jooq/dsl/function/aggregate/BoolAnd.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.jooq.dsl.function.aggregate; 2 | 3 | import org.jooq.Field; 4 | import org.jooq.Name; 5 | import org.jooq.impl.AbstractYdbAggregateFunction; 6 | import tech.ydb.jooq.YdbTypes; 7 | 8 | import static org.jooq.impl.DSL.systemName; 9 | 10 | public final class BoolAnd extends AbstractYdbAggregateFunction { 11 | 12 | private static final Name BOOL_AND = systemName("bool_and"); 13 | 14 | public BoolAnd(Field field) { 15 | super( 16 | false, 17 | BOOL_AND, 18 | YdbTypes.BOOL, 19 | field 20 | ); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /jooq-dialect/src/main/java/tech/ydb/jooq/dsl/function/aggregate/BoolOr.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.jooq.dsl.function.aggregate; 2 | 3 | import org.jooq.Field; 4 | import org.jooq.Name; 5 | import org.jooq.impl.AbstractYdbAggregateFunction; 6 | import tech.ydb.jooq.YdbTypes; 7 | 8 | import static org.jooq.impl.DSL.systemName; 9 | 10 | public final class BoolOr extends AbstractYdbAggregateFunction { 11 | 12 | private static final Name BOOL_OR = systemName("bool_or"); 13 | 14 | public BoolOr(Field field) { 15 | super( 16 | false, 17 | BOOL_OR, 18 | YdbTypes.BOOL, 19 | field 20 | ); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /jooq-dialect/src/main/java/tech/ydb/jooq/dsl/function/aggregate/BoolXor.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.jooq.dsl.function.aggregate; 2 | 3 | import org.jooq.Field; 4 | import org.jooq.Name; 5 | import org.jooq.impl.AbstractYdbAggregateFunction; 6 | import tech.ydb.jooq.YdbTypes; 7 | 8 | import static org.jooq.impl.DSL.systemName; 9 | 10 | public final class BoolXor extends AbstractYdbAggregateFunction { 11 | 12 | private static final Name BOOL_XOR = systemName("bool_xor"); 13 | 14 | public BoolXor(Field field) { 15 | super( 16 | false, 17 | BOOL_XOR, 18 | YdbTypes.BOOL, 19 | field 20 | ); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /jooq-dialect/src/main/java/tech/ydb/jooq/dsl/function/aggregate/Correlation.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.jooq.dsl.function.aggregate; 2 | 3 | import org.jooq.Field; 4 | import org.jooq.Name; 5 | import org.jooq.impl.AbstractYdbAggregateFunction; 6 | import tech.ydb.jooq.YdbTypes; 7 | 8 | import static org.jooq.impl.DSL.systemName; 9 | 10 | public final class Correlation extends AbstractYdbAggregateFunction { 11 | 12 | private static final Name CORRELATION = systemName("correlation"); 13 | 14 | public Correlation(Field field1, Field field2, boolean distinct) { 15 | super( 16 | distinct, 17 | CORRELATION, 18 | YdbTypes.DOUBLE, 19 | field1, 20 | field2 21 | ); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /jooq-dialect/src/main/java/tech/ydb/jooq/dsl/function/aggregate/Count.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.jooq.dsl.function.aggregate; 2 | 3 | import org.jooq.Field; 4 | import org.jooq.Name; 5 | import org.jooq.impl.AbstractYdbAggregateFunction; 6 | import org.jooq.types.ULong; 7 | import tech.ydb.jooq.YdbTypes; 8 | 9 | import static org.jooq.impl.DSL.systemName; 10 | 11 | public final class Count extends AbstractYdbAggregateFunction { 12 | 13 | private static final Name COUNT = systemName("Count"); 14 | 15 | public Count(Field field, boolean distinct) { 16 | super( 17 | distinct, 18 | COUNT, 19 | YdbTypes.UINT64, 20 | field 21 | ); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /jooq-dialect/src/main/java/tech/ydb/jooq/dsl/function/aggregate/CountDistinctEstimate.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.jooq.dsl.function.aggregate; 2 | 3 | import org.jooq.Field; 4 | import org.jooq.Name; 5 | import org.jooq.impl.AbstractYdbAggregateFunction; 6 | import org.jooq.types.ULong; 7 | import tech.ydb.jooq.YdbTypes; 8 | 9 | import static org.jooq.impl.DSL.systemName; 10 | 11 | public final class CountDistinctEstimate extends AbstractYdbAggregateFunction { 12 | 13 | private static final Name COUNT_DISTINCT_ESTIMATE = systemName("CountDistinctEstimate"); 14 | 15 | public CountDistinctEstimate(Field field) { 16 | super( 17 | false, 18 | COUNT_DISTINCT_ESTIMATE, 19 | YdbTypes.UINT64, 20 | field 21 | ); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /jooq-dialect/src/main/java/tech/ydb/jooq/dsl/function/aggregate/CountIf.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.jooq.dsl.function.aggregate; 2 | 3 | import org.jooq.Condition; 4 | import org.jooq.Name; 5 | import org.jooq.impl.AbstractYdbAggregateFunction; 6 | import org.jooq.types.ULong; 7 | import tech.ydb.jooq.YdbTypes; 8 | 9 | import static org.jooq.impl.DSL.systemName; 10 | 11 | public final class CountIf extends AbstractYdbAggregateFunction { 12 | 13 | private static final Name COUNT_IF = systemName("count_if"); 14 | 15 | public CountIf(Condition field) { 16 | super( 17 | false, 18 | COUNT_IF, 19 | YdbTypes.UINT64, 20 | field 21 | ); 22 | } 23 | } 24 | 25 | -------------------------------------------------------------------------------- /jooq-dialect/src/main/java/tech/ydb/jooq/dsl/function/aggregate/Covariance.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.jooq.dsl.function.aggregate; 2 | 3 | import org.jooq.Field; 4 | import org.jooq.Name; 5 | import org.jooq.impl.AbstractYdbAggregateFunction; 6 | import tech.ydb.jooq.YdbTypes; 7 | 8 | import static org.jooq.impl.DSL.systemName; 9 | 10 | public final class Covariance extends AbstractYdbAggregateFunction { 11 | 12 | private static final Name COVARIANCE = systemName("covariance"); 13 | 14 | public Covariance(Field field1, Field field2, boolean distinct) { 15 | super( 16 | distinct, 17 | COVARIANCE, 18 | YdbTypes.DOUBLE, 19 | field1, 20 | field2 21 | ); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /jooq-dialect/src/main/java/tech/ydb/jooq/dsl/function/aggregate/CovariancePopulation.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.jooq.dsl.function.aggregate; 2 | 3 | import org.jooq.Field; 4 | import org.jooq.Name; 5 | import org.jooq.impl.AbstractYdbAggregateFunction; 6 | import tech.ydb.jooq.YdbTypes; 7 | 8 | import static org.jooq.impl.DSL.systemName; 9 | 10 | public final class CovariancePopulation extends AbstractYdbAggregateFunction { 11 | 12 | private static final Name COVARIANCE_POPULATION = systemName("covariance_population"); 13 | 14 | public CovariancePopulation(Field field1, Field field2, boolean distinct) { 15 | super( 16 | distinct, 17 | COVARIANCE_POPULATION, 18 | YdbTypes.DOUBLE, 19 | field1, 20 | field2 21 | ); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /jooq-dialect/src/main/java/tech/ydb/jooq/dsl/function/aggregate/CovarianceSample.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.jooq.dsl.function.aggregate; 2 | 3 | import org.jooq.Field; 4 | import org.jooq.Name; 5 | import org.jooq.impl.AbstractYdbAggregateFunction; 6 | import tech.ydb.jooq.YdbTypes; 7 | 8 | import static org.jooq.impl.DSL.systemName; 9 | 10 | public final class CovarianceSample extends AbstractYdbAggregateFunction { 11 | 12 | private static final Name COVARIANCE_SAMPLE = systemName("covariance_sample"); 13 | 14 | public CovarianceSample(Field field1, Field field2, boolean distinct) { 15 | super( 16 | distinct, 17 | COVARIANCE_SAMPLE, 18 | YdbTypes.DOUBLE, 19 | field1, 20 | field2 21 | ); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /jooq-dialect/src/main/java/tech/ydb/jooq/dsl/function/aggregate/HyperLogLog.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.jooq.dsl.function.aggregate; 2 | 3 | import org.jooq.Field; 4 | import org.jooq.Name; 5 | import org.jooq.impl.AbstractYdbAggregateFunction; 6 | import org.jooq.types.ULong; 7 | import tech.ydb.jooq.YdbTypes; 8 | 9 | import static org.jooq.impl.DSL.systemName; 10 | 11 | public final class HyperLogLog extends AbstractYdbAggregateFunction { 12 | 13 | private static final Name HYPER_LOG_LOG = systemName("HyperLogLog"); 14 | 15 | public HyperLogLog(Field field) { 16 | super( 17 | false, 18 | HYPER_LOG_LOG, 19 | YdbTypes.UINT64, 20 | field 21 | ); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /jooq-dialect/src/main/java/tech/ydb/jooq/dsl/function/aggregate/Max.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.jooq.dsl.function.aggregate; 2 | 3 | import org.jooq.Field; 4 | import org.jooq.Name; 5 | import org.jooq.impl.AbstractYdbAggregateFunction; 6 | 7 | import static org.jooq.impl.DSL.systemName; 8 | 9 | public final class Max extends AbstractYdbAggregateFunction { 10 | 11 | private static final Name MAX = systemName("Max"); 12 | 13 | public Max(Field field, boolean distinct) { 14 | super( 15 | distinct, 16 | MAX, 17 | field.getDataType(), 18 | field 19 | ); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /jooq-dialect/src/main/java/tech/ydb/jooq/dsl/function/aggregate/MaxBy.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.jooq.dsl.function.aggregate; 2 | 3 | import org.jooq.Field; 4 | import org.jooq.Name; 5 | import org.jooq.impl.AbstractYdbAggregateFunction; 6 | 7 | import static org.jooq.impl.DSL.systemName; 8 | 9 | public final class MaxBy extends AbstractYdbAggregateFunction { 10 | 11 | private static final Name MAX_BY = systemName("max_by"); 12 | 13 | public MaxBy(Field field, Field cmp) { 14 | super( 15 | false, 16 | MAX_BY, 17 | field.getDataType(), 18 | field, 19 | cmp 20 | ); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /jooq-dialect/src/main/java/tech/ydb/jooq/dsl/function/aggregate/Median.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.jooq.dsl.function.aggregate; 2 | 3 | import org.jooq.Field; 4 | import org.jooq.Name; 5 | import org.jooq.impl.AbstractYdbAggregateFunction; 6 | 7 | import static org.jooq.impl.DSL.systemName; 8 | 9 | public final class Median extends AbstractYdbAggregateFunction { 10 | 11 | private static final Name MEDIAN = systemName("median"); 12 | 13 | public Median(Field field, Field percent, boolean distinct) { 14 | super( 15 | distinct, 16 | MEDIAN, 17 | field.getDataType(), 18 | percent != null ? new Field[]{field, percent} : new Field[]{field} 19 | ); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /jooq-dialect/src/main/java/tech/ydb/jooq/dsl/function/aggregate/Min.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.jooq.dsl.function.aggregate; 2 | 3 | import org.jooq.Field; 4 | import org.jooq.Name; 5 | import org.jooq.impl.AbstractYdbAggregateFunction; 6 | 7 | import static org.jooq.impl.DSL.systemName; 8 | 9 | public final class Min extends AbstractYdbAggregateFunction { 10 | 11 | private static final Name MIN = systemName("Min"); 12 | 13 | public Min(Field field, boolean distinct) { 14 | super( 15 | distinct, 16 | MIN, 17 | field.getDataType(), 18 | field 19 | ); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /jooq-dialect/src/main/java/tech/ydb/jooq/dsl/function/aggregate/MinBy.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.jooq.dsl.function.aggregate; 2 | 3 | import org.jooq.Field; 4 | import org.jooq.Name; 5 | import org.jooq.impl.AbstractYdbAggregateFunction; 6 | 7 | import static org.jooq.impl.DSL.systemName; 8 | 9 | public final class MinBy extends AbstractYdbAggregateFunction { 10 | 11 | private static final Name MIN_BY = systemName("min_by"); 12 | 13 | public MinBy(Field field, Field cmp) { 14 | super( 15 | false, 16 | MIN_BY, 17 | field.getDataType(), 18 | field, 19 | cmp 20 | ); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /jooq-dialect/src/main/java/tech/ydb/jooq/dsl/function/aggregate/Percentile.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.jooq.dsl.function.aggregate; 2 | 3 | import org.jooq.Field; 4 | import org.jooq.Name; 5 | import org.jooq.impl.AbstractYdbAggregateFunction; 6 | 7 | import static org.jooq.impl.DSL.systemName; 8 | 9 | public final class Percentile extends AbstractYdbAggregateFunction { 10 | 11 | private static final Name PERCENTILE = systemName("percentile"); 12 | 13 | public Percentile(Field field, Field percent, boolean distinct) { 14 | super( 15 | distinct, 16 | PERCENTILE, 17 | field.getDataType(), 18 | field, 19 | percent 20 | ); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /jooq-dialect/src/main/java/tech/ydb/jooq/dsl/function/aggregate/PopulationStdDev.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.jooq.dsl.function.aggregate; 2 | 3 | import org.jooq.Field; 4 | import org.jooq.Name; 5 | import org.jooq.impl.AbstractYdbAggregateFunction; 6 | import tech.ydb.jooq.YdbTypes; 7 | 8 | import static org.jooq.impl.DSL.systemName; 9 | 10 | public final class PopulationStdDev extends AbstractYdbAggregateFunction { 11 | 12 | private static final Name POPULATION_STDDEV = systemName("population_stddev"); 13 | 14 | public PopulationStdDev(Field field, boolean distinct) { 15 | super( 16 | distinct, 17 | POPULATION_STDDEV, 18 | YdbTypes.DOUBLE, 19 | field 20 | ); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /jooq-dialect/src/main/java/tech/ydb/jooq/dsl/function/aggregate/PopulationVariance.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.jooq.dsl.function.aggregate; 2 | 3 | import org.jooq.Field; 4 | import org.jooq.Name; 5 | import org.jooq.impl.AbstractYdbAggregateFunction; 6 | import tech.ydb.jooq.YdbTypes; 7 | 8 | import static org.jooq.impl.DSL.systemName; 9 | 10 | public final class PopulationVariance extends AbstractYdbAggregateFunction { 11 | 12 | private static final Name POPULATION_VARIANCE = systemName("population_variance"); 13 | 14 | public PopulationVariance(Field field, boolean distinct) { 15 | super( 16 | distinct, 17 | POPULATION_VARIANCE, 18 | YdbTypes.DOUBLE, 19 | field 20 | ); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /jooq-dialect/src/main/java/tech/ydb/jooq/dsl/function/aggregate/Some.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.jooq.dsl.function.aggregate; 2 | 3 | import org.jooq.Field; 4 | import org.jooq.Name; 5 | import org.jooq.impl.AbstractYdbAggregateFunction; 6 | 7 | import static org.jooq.impl.DSL.systemName; 8 | 9 | public final class Some extends AbstractYdbAggregateFunction { 10 | 11 | private static final Name SOME = systemName("some"); 12 | 13 | public Some(Field field, boolean distinct) { 14 | super( 15 | distinct, 16 | SOME, 17 | field.getDataType(), 18 | field 19 | ); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /jooq-dialect/src/main/java/tech/ydb/jooq/dsl/function/aggregate/StdDev.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.jooq.dsl.function.aggregate; 2 | 3 | import org.jooq.Field; 4 | import org.jooq.Name; 5 | import org.jooq.impl.AbstractYdbAggregateFunction; 6 | import tech.ydb.jooq.YdbTypes; 7 | 8 | import static org.jooq.impl.DSL.systemName; 9 | 10 | public final class StdDev extends AbstractYdbAggregateFunction { 11 | 12 | private static final Name STDDEV = systemName("stddev"); 13 | 14 | public StdDev(Field field, boolean distinct) { 15 | super( 16 | distinct, 17 | STDDEV, 18 | YdbTypes.DOUBLE, 19 | field 20 | ); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /jooq-dialect/src/main/java/tech/ydb/jooq/dsl/function/aggregate/StdDevPopulation.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.jooq.dsl.function.aggregate; 2 | 3 | import org.jooq.Field; 4 | import org.jooq.Name; 5 | import org.jooq.impl.AbstractYdbAggregateFunction; 6 | import tech.ydb.jooq.YdbTypes; 7 | 8 | import static org.jooq.impl.DSL.systemName; 9 | 10 | public final class StdDevPopulation extends AbstractYdbAggregateFunction { 11 | 12 | private static final Name STDDEV_POPULATION = systemName("stddev_population"); 13 | 14 | public StdDevPopulation(Field field, boolean distinct) { 15 | super( 16 | distinct, 17 | STDDEV_POPULATION, 18 | YdbTypes.DOUBLE, 19 | field 20 | ); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /jooq-dialect/src/main/java/tech/ydb/jooq/dsl/function/aggregate/StdDevSample.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.jooq.dsl.function.aggregate; 2 | 3 | import org.jooq.Field; 4 | import org.jooq.Name; 5 | import org.jooq.impl.AbstractYdbAggregateFunction; 6 | import tech.ydb.jooq.YdbTypes; 7 | 8 | import static org.jooq.impl.DSL.systemName; 9 | 10 | public final class StdDevSample extends AbstractYdbAggregateFunction { 11 | 12 | private static final Name STDDEV_SAMPLE = systemName("stddev_sample"); 13 | 14 | public StdDevSample(Field field, boolean distinct) { 15 | super( 16 | distinct, 17 | STDDEV_SAMPLE, 18 | YdbTypes.DOUBLE, 19 | field 20 | ); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /jooq-dialect/src/main/java/tech/ydb/jooq/dsl/function/aggregate/Sum.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.jooq.dsl.function.aggregate; 2 | 3 | import org.jooq.DataType; 4 | import org.jooq.Field; 5 | import org.jooq.Name; 6 | import org.jooq.impl.AbstractYdbAggregateFunction; 7 | 8 | import static org.jooq.impl.DSL.systemName; 9 | 10 | public final class Sum extends AbstractYdbAggregateFunction { 11 | 12 | private static final Name SUM = systemName("Sum"); 13 | 14 | public Sum(Field field, boolean distinct, DataType type) { 15 | super( 16 | distinct, 17 | SUM, 18 | type, 19 | field 20 | ); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /jooq-dialect/src/main/java/tech/ydb/jooq/dsl/function/aggregate/SumIf.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.jooq.dsl.function.aggregate; 2 | 3 | import org.jooq.Condition; 4 | import org.jooq.DataType; 5 | import org.jooq.Field; 6 | import org.jooq.Name; 7 | import org.jooq.impl.AbstractYdbAggregateFunction; 8 | 9 | import static org.jooq.impl.DSL.systemName; 10 | 11 | public final class SumIf extends AbstractYdbAggregateFunction { 12 | 13 | private static final Name SUM_IF = systemName("sum_if"); 14 | 15 | public SumIf(Field field, Condition condition, boolean distinct, DataType type) { 16 | super( 17 | distinct, 18 | SUM_IF, 19 | type, 20 | field, 21 | condition 22 | ); 23 | } 24 | } 25 | 26 | -------------------------------------------------------------------------------- /jooq-dialect/src/main/java/tech/ydb/jooq/dsl/function/aggregate/Variance.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.jooq.dsl.function.aggregate; 2 | 3 | import org.jooq.Field; 4 | import org.jooq.Name; 5 | import org.jooq.impl.AbstractYdbAggregateFunction; 6 | import tech.ydb.jooq.YdbTypes; 7 | 8 | import static org.jooq.impl.DSL.systemName; 9 | 10 | public final class Variance extends AbstractYdbAggregateFunction { 11 | 12 | private static final Name VARIANCE = systemName("variance"); 13 | 14 | public Variance(Field field, boolean distinct) { 15 | super( 16 | distinct, 17 | VARIANCE, 18 | YdbTypes.DOUBLE, 19 | field 20 | ); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /jooq-dialect/src/main/java/tech/ydb/jooq/dsl/function/aggregate/VariancePopulation.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.jooq.dsl.function.aggregate; 2 | 3 | import org.jooq.Field; 4 | import org.jooq.Name; 5 | import org.jooq.impl.AbstractYdbAggregateFunction; 6 | import tech.ydb.jooq.YdbTypes; 7 | 8 | import static org.jooq.impl.DSL.systemName; 9 | 10 | public final class VariancePopulation extends AbstractYdbAggregateFunction { 11 | 12 | private static final Name VARIANCE_POPULATION = systemName("variance_population"); 13 | 14 | public VariancePopulation(Field field, boolean distinct) { 15 | super( 16 | distinct, 17 | VARIANCE_POPULATION, 18 | YdbTypes.DOUBLE, 19 | field 20 | ); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /jooq-dialect/src/main/java/tech/ydb/jooq/dsl/function/aggregate/VarianceSample.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.jooq.dsl.function.aggregate; 2 | 3 | import org.jooq.Field; 4 | import org.jooq.Name; 5 | import org.jooq.impl.AbstractYdbAggregateFunction; 6 | import tech.ydb.jooq.YdbTypes; 7 | 8 | import static org.jooq.impl.DSL.systemName; 9 | 10 | public final class VarianceSample extends AbstractYdbAggregateFunction { 11 | 12 | private static final Name VARIANCE_SAMPLE = systemName("variance_sample"); 13 | 14 | public VarianceSample(Field field, boolean distinct) { 15 | super( 16 | distinct, 17 | VARIANCE_SAMPLE, 18 | YdbTypes.DOUBLE, 19 | field 20 | ); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /jooq-dialect/src/main/java/tech/ydb/jooq/dsl/function/builtin/Abs.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.jooq.dsl.function.builtin; 2 | 3 | import org.jooq.Context; 4 | import org.jooq.Field; 5 | import org.jooq.Name; 6 | import org.jooq.impl.AbstractYdbFunction; 7 | 8 | import static org.jooq.impl.DSL.function; 9 | import static org.jooq.impl.DSL.systemName; 10 | 11 | public final class Abs extends AbstractYdbFunction { 12 | 13 | private static final Name ABS = systemName("Abs"); 14 | 15 | private final Field value; 16 | 17 | public Abs(Field value) { 18 | super( 19 | ABS, 20 | value.getDataType() 21 | ); 22 | 23 | this.value = value; 24 | } 25 | 26 | @Override 27 | public void accept(Context ctx) { 28 | ctx.visit(function(ABS, getDataType(), value)); 29 | } 30 | } 31 | 32 | -------------------------------------------------------------------------------- /jooq-dialect/src/main/java/tech/ydb/jooq/dsl/function/builtin/AddTimezone.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.jooq.dsl.function.builtin; 2 | 3 | import org.jooq.Context; 4 | import org.jooq.Field; 5 | import org.jooq.Name; 6 | import org.jooq.impl.AbstractYdbFunction; 7 | import tech.ydb.jooq.YdbTypes; 8 | 9 | import java.time.ZonedDateTime; 10 | 11 | import static org.jooq.impl.DSL.function; 12 | import static org.jooq.impl.DSL.systemName; 13 | 14 | public final class AddTimezone extends AbstractYdbFunction { 15 | 16 | private static final Name ADD_TIMEZONE = systemName("AddTimezone"); 17 | 18 | private final Field date; 19 | private final Field timeZone; 20 | 21 | public AddTimezone(Field date, Field timeZone) { 22 | super( 23 | ADD_TIMEZONE, 24 | YdbTypes.TZ_DATE 25 | ); 26 | 27 | this.date = date; 28 | this.timeZone = timeZone; 29 | } 30 | 31 | @Override 32 | public void accept(Context ctx) { 33 | ctx.visit(function(ADD_TIMEZONE, getDataType(), date, timeZone)); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /jooq-dialect/src/main/java/tech/ydb/jooq/dsl/function/builtin/AssumeStrict.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.jooq.dsl.function.builtin; 2 | 3 | import org.jooq.Context; 4 | import org.jooq.Field; 5 | import org.jooq.Name; 6 | import org.jooq.impl.AbstractYdbFunction; 7 | 8 | import static org.jooq.impl.DSL.function; 9 | import static org.jooq.impl.DSL.systemName; 10 | 11 | public final class AssumeStrict extends AbstractYdbFunction { 12 | 13 | private static final Name ASSUME_STRICT = systemName("AssumeStrict"); 14 | 15 | private final Field value; 16 | 17 | public AssumeStrict(Field value) { 18 | super( 19 | ASSUME_STRICT, 20 | value.getDataType() 21 | ); 22 | 23 | this.value = value; 24 | } 25 | 26 | @Override 27 | public void accept(Context ctx) { 28 | ctx.visit(function(ASSUME_STRICT, getDataType(), value)); 29 | } 30 | } 31 | 32 | -------------------------------------------------------------------------------- /jooq-dialect/src/main/java/tech/ydb/jooq/dsl/function/builtin/ByteAt.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.jooq.dsl.function.builtin; 2 | 3 | import org.jooq.Context; 4 | import org.jooq.Field; 5 | import org.jooq.Name; 6 | import org.jooq.impl.AbstractYdbFunction; 7 | import org.jooq.types.UByte; 8 | import org.jooq.types.UInteger; 9 | import tech.ydb.jooq.YdbTypes; 10 | 11 | import static org.jooq.impl.DSL.function; 12 | import static org.jooq.impl.DSL.systemName; 13 | 14 | public final class ByteAt extends AbstractYdbFunction { 15 | 16 | private static final Name BYTE_AT = systemName("ByteAt"); 17 | 18 | private final Field source; 19 | private final Field index; 20 | 21 | public ByteAt(Field source, Field index) { 22 | super( 23 | BYTE_AT, 24 | YdbTypes.UINT8 25 | ); 26 | 27 | this.source = source; 28 | this.index = index; 29 | } 30 | 31 | @Override 32 | public void accept(Context ctx) { 33 | ctx.visit(function(BYTE_AT, getDataType(), source, index)); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /jooq-dialect/src/main/java/tech/ydb/jooq/dsl/function/builtin/ClearBit.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.jooq.dsl.function.builtin; 2 | 3 | import org.jooq.Context; 4 | import org.jooq.Field; 5 | import org.jooq.Name; 6 | import org.jooq.impl.AbstractYdbFunction; 7 | import org.jooq.types.UByte; 8 | import org.jooq.types.UNumber; 9 | 10 | import static org.jooq.impl.DSL.function; 11 | import static org.jooq.impl.DSL.systemName; 12 | 13 | public final class ClearBit extends AbstractYdbFunction { 14 | 15 | private static final Name CLEAR_BIT = systemName("ClearBit"); 16 | 17 | private final Field value; 18 | private final Field index; 19 | 20 | public ClearBit(Field value, Field index) { 21 | super( 22 | CLEAR_BIT, 23 | value.getDataType() 24 | ); 25 | 26 | this.value = value; 27 | this.index = index; 28 | } 29 | 30 | @Override 31 | public void accept(Context ctx) { 32 | ctx.visit(function(CLEAR_BIT, getDataType(), value, index)); 33 | } 34 | } 35 | 36 | -------------------------------------------------------------------------------- /jooq-dialect/src/main/java/tech/ydb/jooq/dsl/function/builtin/Coalesce.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.jooq.dsl.function.builtin; 2 | 3 | import org.jooq.Context; 4 | import org.jooq.Field; 5 | import org.jooq.Name; 6 | import org.jooq.impl.AbstractYdbFunction; 7 | 8 | import static org.jooq.impl.DSL.function; 9 | import static org.jooq.impl.DSL.systemName; 10 | 11 | public final class Coalesce extends AbstractYdbFunction { 12 | 13 | private static final Name COALESCE = systemName("coalesce"); 14 | 15 | private final Field[] fields; 16 | 17 | public Coalesce(Field[] fields) { 18 | super( 19 | COALESCE, 20 | fields[0].getDataType() 21 | ); 22 | 23 | this.fields = fields; 24 | } 25 | 26 | @Override 27 | public void accept(Context ctx) { 28 | ctx.visit(function(COALESCE, getDataType(), fields)); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /jooq-dialect/src/main/java/tech/ydb/jooq/dsl/function/builtin/CurrentTzDate.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.jooq.dsl.function.builtin; 2 | 3 | import org.jooq.Context; 4 | import org.jooq.Field; 5 | import org.jooq.Name; 6 | import org.jooq.impl.AbstractYdbFunction; 7 | import tech.ydb.jooq.YdbTypes; 8 | 9 | import java.time.ZonedDateTime; 10 | 11 | import static org.jooq.impl.DSL.function; 12 | import static org.jooq.impl.DSL.systemName; 13 | import static org.jooq.impl.YdbTools.combine; 14 | 15 | public final class CurrentTzDate extends AbstractYdbFunction { 16 | 17 | private static final Name CURRENT_TZ_DATE = systemName("CurrentTzDate"); 18 | 19 | private final Field timeZone; 20 | private final Field[] fields; 21 | 22 | public CurrentTzDate(Field timeZone, Field[] fields) { 23 | super( 24 | CURRENT_TZ_DATE, 25 | YdbTypes.TZ_DATE 26 | ); 27 | 28 | this.timeZone = timeZone; 29 | this.fields = fields; 30 | } 31 | 32 | @Override 33 | public void accept(Context ctx) { 34 | ctx.visit(function(CURRENT_TZ_DATE, getDataType(), combine(timeZone, fields))); 35 | } 36 | } 37 | 38 | -------------------------------------------------------------------------------- /jooq-dialect/src/main/java/tech/ydb/jooq/dsl/function/builtin/CurrentTzDatetime.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.jooq.dsl.function.builtin; 2 | 3 | import org.jooq.Context; 4 | import org.jooq.Field; 5 | import org.jooq.Name; 6 | import org.jooq.impl.AbstractYdbFunction; 7 | import tech.ydb.jooq.YdbTypes; 8 | 9 | import java.time.ZonedDateTime; 10 | 11 | import static org.jooq.impl.DSL.function; 12 | import static org.jooq.impl.DSL.systemName; 13 | import static org.jooq.impl.YdbTools.combine; 14 | 15 | public final class CurrentTzDatetime extends AbstractYdbFunction { 16 | 17 | private static final Name CURRENT_TZ_DATETIME = systemName("CurrentTzDatetime"); 18 | 19 | private final Field timeZone; 20 | private final Field[] fields; 21 | 22 | public CurrentTzDatetime(Field timeZone, Field[] fields) { 23 | super( 24 | CURRENT_TZ_DATETIME, 25 | YdbTypes.TZ_DATETIME 26 | ); 27 | 28 | this.timeZone = timeZone; 29 | this.fields = fields; 30 | } 31 | 32 | @Override 33 | public void accept(Context ctx) { 34 | ctx.visit(function(CURRENT_TZ_DATETIME, getDataType(), combine(timeZone, fields))); 35 | } 36 | } 37 | 38 | 39 | -------------------------------------------------------------------------------- /jooq-dialect/src/main/java/tech/ydb/jooq/dsl/function/builtin/CurrentTzTimestamp.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.jooq.dsl.function.builtin; 2 | 3 | import org.jooq.Context; 4 | import org.jooq.Field; 5 | import org.jooq.Name; 6 | import org.jooq.impl.AbstractYdbFunction; 7 | import tech.ydb.jooq.YdbTypes; 8 | 9 | import java.time.ZonedDateTime; 10 | 11 | import static org.jooq.impl.DSL.function; 12 | import static org.jooq.impl.DSL.systemName; 13 | import static org.jooq.impl.YdbTools.combine; 14 | 15 | public final class CurrentTzTimestamp extends AbstractYdbFunction { 16 | 17 | private static final Name CURRENT_TZ_TIMESTAMP = systemName("CurrentTzTimestamp"); 18 | 19 | private final Field timeZone; 20 | private final Field[] fields; 21 | 22 | public CurrentTzTimestamp(Field timeZone, Field[] fields) { 23 | super( 24 | CURRENT_TZ_TIMESTAMP, 25 | YdbTypes.TZ_TIMESTAMP 26 | ); 27 | 28 | this.timeZone = timeZone; 29 | this.fields = fields; 30 | } 31 | 32 | @Override 33 | public void accept(Context ctx) { 34 | ctx.visit(function(CURRENT_TZ_TIMESTAMP, getDataType(), combine(timeZone, fields))); 35 | } 36 | } 37 | 38 | -------------------------------------------------------------------------------- /jooq-dialect/src/main/java/tech/ydb/jooq/dsl/function/builtin/CurrentUtcDate.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.jooq.dsl.function.builtin; 2 | 3 | import org.jooq.Context; 4 | import org.jooq.Field; 5 | import org.jooq.Name; 6 | import org.jooq.impl.AbstractYdbFunction; 7 | import tech.ydb.jooq.YdbTypes; 8 | 9 | import java.time.LocalDate; 10 | 11 | import static org.jooq.impl.DSL.function; 12 | import static org.jooq.impl.DSL.systemName; 13 | 14 | public final class CurrentUtcDate extends AbstractYdbFunction { 15 | 16 | private static final Name CURRENT_UTC_DATE = systemName("CurrentUtcDate"); 17 | 18 | private final Field[] fields; 19 | 20 | public CurrentUtcDate(Field[] fields) { 21 | super( 22 | CURRENT_UTC_DATE, 23 | YdbTypes.DATE 24 | ); 25 | 26 | this.fields = fields; 27 | } 28 | 29 | @Override 30 | public void accept(Context ctx) { 31 | ctx.visit(function(CURRENT_UTC_DATE, getDataType(), fields)); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /jooq-dialect/src/main/java/tech/ydb/jooq/dsl/function/builtin/CurrentUtcDatetime.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.jooq.dsl.function.builtin; 2 | 3 | import org.jooq.Context; 4 | import org.jooq.Field; 5 | import org.jooq.Name; 6 | import org.jooq.impl.AbstractYdbFunction; 7 | import tech.ydb.jooq.YdbTypes; 8 | 9 | import java.time.LocalDateTime; 10 | 11 | import static org.jooq.impl.DSL.function; 12 | import static org.jooq.impl.DSL.systemName; 13 | 14 | public final class CurrentUtcDatetime extends AbstractYdbFunction { 15 | 16 | private static final Name CURRENT_UTC_DATETIME = systemName("CurrentUtcDatetime"); 17 | 18 | private final Field[] fields; 19 | 20 | public CurrentUtcDatetime(Field[] fields) { 21 | super( 22 | CURRENT_UTC_DATETIME, 23 | YdbTypes.DATETIME 24 | ); 25 | 26 | this.fields = fields; 27 | } 28 | 29 | @Override 30 | public void accept(Context ctx) { 31 | ctx.visit(function(CURRENT_UTC_DATETIME, getDataType(), fields)); 32 | } 33 | } -------------------------------------------------------------------------------- /jooq-dialect/src/main/java/tech/ydb/jooq/dsl/function/builtin/CurrentUtcTimestamp.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.jooq.dsl.function.builtin; 2 | 3 | import org.jooq.Context; 4 | import org.jooq.Field; 5 | import org.jooq.Name; 6 | import org.jooq.impl.AbstractYdbFunction; 7 | import tech.ydb.jooq.YdbTypes; 8 | 9 | import java.time.Instant; 10 | 11 | import static org.jooq.impl.DSL.function; 12 | import static org.jooq.impl.DSL.systemName; 13 | 14 | public final class CurrentUtcTimestamp extends AbstractYdbFunction { 15 | 16 | private static final Name CURRENT_UTC_TIMESTAMP = systemName("CurrentUtcTimestamp"); 17 | 18 | private final Field[] fields; 19 | 20 | public CurrentUtcTimestamp(Field[] fields) { 21 | super( 22 | CURRENT_UTC_TIMESTAMP, 23 | YdbTypes.TIMESTAMP 24 | ); 25 | 26 | this.fields = fields; 27 | } 28 | 29 | @Override 30 | public void accept(Context ctx) { 31 | ctx.visit(function(CURRENT_UTC_TIMESTAMP, getDataType(), fields)); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /jooq-dialect/src/main/java/tech/ydb/jooq/dsl/function/builtin/EndsWith.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.jooq.dsl.function.builtin; 2 | 3 | import org.jooq.Context; 4 | import org.jooq.Field; 5 | import org.jooq.Name; 6 | import org.jooq.impl.AbstractYdbCondition; 7 | 8 | import static org.jooq.impl.DSL.function; 9 | import static org.jooq.impl.DSL.systemName; 10 | 11 | public final class EndsWith extends AbstractYdbCondition { 12 | 13 | private static final Name ENDS_WITH = systemName("EndsWith"); 14 | 15 | private final Field source; 16 | private final Field substring; 17 | 18 | public EndsWith(Field source, Field substring) { 19 | this.source = source; 20 | this.substring = substring; 21 | } 22 | 23 | @Override 24 | public void accept(Context ctx) { 25 | ctx.visit(function(ENDS_WITH, getDataType(), source, substring)); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /jooq-dialect/src/main/java/tech/ydb/jooq/dsl/function/builtin/Ensure.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.jooq.dsl.function.builtin; 2 | 3 | import org.jooq.Condition; 4 | import org.jooq.Context; 5 | import org.jooq.Field; 6 | import org.jooq.Name; 7 | import org.jooq.impl.AbstractYdbFunction; 8 | 9 | import static org.jooq.impl.DSL.*; 10 | 11 | public final class Ensure extends AbstractYdbFunction { 12 | 13 | private static final Name ENSURE = systemName("Ensure"); 14 | 15 | private final Field value; 16 | private final Condition condition; 17 | private final Field message; 18 | 19 | public Ensure(Field value, Condition condition, Field message) { 20 | super( 21 | ENSURE, 22 | value.getDataType() 23 | ); 24 | 25 | this.value = value; 26 | this.condition = condition; 27 | this.message = message; 28 | } 29 | 30 | @Override 31 | public void accept(Context ctx) { 32 | if (message != null) { 33 | ctx.visit(function(ENSURE, getDataType(), value, condition, message)); 34 | } else { 35 | ctx.visit(function(ENSURE, getDataType(), value, condition)); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /jooq-dialect/src/main/java/tech/ydb/jooq/dsl/function/builtin/Find.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.jooq.dsl.function.builtin; 2 | 3 | import org.jooq.Context; 4 | import org.jooq.Field; 5 | import org.jooq.Name; 6 | import org.jooq.impl.AbstractYdbFunction; 7 | import org.jooq.types.UInteger; 8 | import tech.ydb.jooq.YdbTypes; 9 | 10 | import static org.jooq.impl.DSL.function; 11 | import static org.jooq.impl.DSL.systemName; 12 | 13 | public final class Find extends AbstractYdbFunction { 14 | 15 | private static final Name FIND = systemName("find"); 16 | 17 | private final Field source; 18 | private final Field substring; 19 | private final Field startingPosition; 20 | 21 | public Find(Field source, Field substring, Field startingPosition) { 22 | super( 23 | FIND, 24 | YdbTypes.UINT32 25 | ); 26 | 27 | this.source = source; 28 | this.substring = substring; 29 | this.startingPosition = startingPosition; 30 | } 31 | 32 | @Override 33 | public void accept(Context ctx) { 34 | if (startingPosition != null) { 35 | ctx.visit(function(FIND, getDataType(), source, substring, startingPosition)); 36 | } else { 37 | ctx.visit(function(FIND, getDataType(), source, substring)); 38 | } 39 | } 40 | } -------------------------------------------------------------------------------- /jooq-dialect/src/main/java/tech/ydb/jooq/dsl/function/builtin/FlipBit.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.jooq.dsl.function.builtin; 2 | 3 | import org.jooq.Context; 4 | import org.jooq.Field; 5 | import org.jooq.Name; 6 | import org.jooq.impl.AbstractYdbFunction; 7 | import org.jooq.types.UByte; 8 | import org.jooq.types.UNumber; 9 | 10 | import static org.jooq.impl.DSL.function; 11 | import static org.jooq.impl.DSL.systemName; 12 | 13 | public final class FlipBit extends AbstractYdbFunction { 14 | 15 | private static final Name FLIP_BIT = systemName("FlipBit"); 16 | 17 | private final Field value; 18 | private final Field index; 19 | 20 | public FlipBit(Field value, Field index) { 21 | super( 22 | FLIP_BIT, 23 | value.getDataType() 24 | ); 25 | 26 | this.value = value; 27 | this.index = index; 28 | } 29 | 30 | @Override 31 | public void accept(Context ctx) { 32 | ctx.visit(function(FLIP_BIT, getDataType(), value, index)); 33 | } 34 | } 35 | 36 | -------------------------------------------------------------------------------- /jooq-dialect/src/main/java/tech/ydb/jooq/dsl/function/builtin/FromBytes.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.jooq.dsl.function.builtin; 2 | 3 | import org.jooq.Context; 4 | import org.jooq.DataType; 5 | import org.jooq.Field; 6 | import org.jooq.Name; 7 | import org.jooq.impl.AbstractYdbFunction; 8 | 9 | import static org.jooq.impl.DSL.function; 10 | import static org.jooq.impl.DSL.inline; 11 | import static org.jooq.impl.DSL.systemName; 12 | 13 | public final class FromBytes extends AbstractYdbFunction { 14 | 15 | private static final Name FROM_BYTES = systemName("FromBytes"); 16 | 17 | private final Field bytes; 18 | private final DataType type; 19 | 20 | public FromBytes(Field bytes, DataType type) { 21 | super( 22 | FROM_BYTES, 23 | type 24 | ); 25 | 26 | this.bytes = bytes; 27 | this.type = type; 28 | } 29 | 30 | @Override 31 | public void accept(Context ctx) { 32 | ctx.visit(function(FROM_BYTES, getDataType(), bytes, inline(type.getTypeName()))); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /jooq-dialect/src/main/java/tech/ydb/jooq/dsl/function/builtin/If.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.jooq.dsl.function.builtin; 2 | 3 | import org.jooq.Condition; 4 | import org.jooq.Context; 5 | import org.jooq.Field; 6 | import org.jooq.Name; 7 | import org.jooq.impl.AbstractYdbFunction; 8 | 9 | import static org.jooq.impl.DSL.function; 10 | import static org.jooq.impl.DSL.systemName; 11 | 12 | public final class If extends AbstractYdbFunction { 13 | 14 | private static final Name IF = systemName("if"); 15 | 16 | private final Condition condition; 17 | private final Field ifTrue; 18 | private final Field ifFalse; 19 | 20 | public If(Condition condition, Field ifTrue, Field ifFalse) { 21 | super( 22 | IF, 23 | ifTrue.getDataType() 24 | ); 25 | 26 | this.condition = condition; 27 | this.ifTrue = ifTrue; 28 | this.ifFalse = ifFalse; 29 | } 30 | 31 | @Override 32 | public void accept(Context ctx) { 33 | if (ifFalse != null) { 34 | ctx.visit(function(IF, getDataType(), condition, ifTrue, ifFalse)); 35 | } else { 36 | ctx.visit(function(IF, getDataType(), condition, ifTrue)); 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /jooq-dialect/src/main/java/tech/ydb/jooq/dsl/function/builtin/JoinTableRow.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.jooq.dsl.function.builtin; 2 | 3 | import org.jooq.Context; 4 | import org.jooq.Name; 5 | import org.jooq.impl.AbstractYdbFunction; 6 | import org.jooq.impl.SQLDataType; 7 | 8 | import static org.jooq.impl.DSL.function; 9 | import static org.jooq.impl.DSL.systemName; 10 | 11 | public final class JoinTableRow extends AbstractYdbFunction { 12 | 13 | private static final Name JOIN_TABLE_ROW = systemName("JoinTableRow"); 14 | 15 | public JoinTableRow() { 16 | super( 17 | JOIN_TABLE_ROW, 18 | SQLDataType.OTHER 19 | ); 20 | } 21 | 22 | @Override 23 | public void accept(Context ctx) { 24 | ctx.visit(function(JOIN_TABLE_ROW, getDataType())); 25 | } 26 | } 27 | 28 | -------------------------------------------------------------------------------- /jooq-dialect/src/main/java/tech/ydb/jooq/dsl/function/builtin/Just.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.jooq.dsl.function.builtin; 2 | 3 | import org.jooq.Context; 4 | import org.jooq.Field; 5 | import org.jooq.Name; 6 | import org.jooq.impl.AbstractYdbFunction; 7 | 8 | import static org.jooq.impl.DSL.function; 9 | import static org.jooq.impl.DSL.systemName; 10 | 11 | public final class Just extends AbstractYdbFunction { 12 | 13 | private static final Name JUST = systemName("Just"); 14 | 15 | private final Field value; 16 | 17 | public Just(Field value) { 18 | super( 19 | JUST, 20 | value.getDataType() 21 | ); 22 | 23 | this.value = value; 24 | } 25 | 26 | @Override 27 | public void accept(Context ctx) { 28 | ctx.visit(function(JUST, getDataType(), value)); 29 | } 30 | } 31 | 32 | -------------------------------------------------------------------------------- /jooq-dialect/src/main/java/tech/ydb/jooq/dsl/function/builtin/Length.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.jooq.dsl.function.builtin; 2 | 3 | import org.jooq.*; 4 | import org.jooq.impl.AbstractYdbFunction; 5 | import org.jooq.types.UInteger; 6 | import tech.ydb.jooq.YdbTypes; 7 | 8 | import static org.jooq.impl.DSL.function; 9 | import static org.jooq.impl.DSL.systemName; 10 | 11 | public final class Length extends AbstractYdbFunction { 12 | 13 | private static final Name LENGTH = systemName("length"); 14 | 15 | private final Field value; 16 | 17 | public Length(Field value) { 18 | super( 19 | LENGTH, 20 | YdbTypes.UINT32 21 | ); 22 | 23 | this.value = value; 24 | } 25 | 26 | @Override 27 | public void accept(Context ctx) { 28 | ctx.visit(function(LENGTH, getDataType(), value)); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /jooq-dialect/src/main/java/tech/ydb/jooq/dsl/function/builtin/Likely.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.jooq.dsl.function.builtin; 2 | 3 | import org.jooq.Condition; 4 | import org.jooq.Context; 5 | import org.jooq.Name; 6 | import org.jooq.impl.AbstractYdbCondition; 7 | 8 | import static org.jooq.impl.DSL.function; 9 | import static org.jooq.impl.DSL.systemName; 10 | 11 | public final class Likely extends AbstractYdbCondition { 12 | 13 | private static final Name LIKELY = systemName("Likely"); 14 | 15 | private final Condition condition; 16 | 17 | public Likely(Condition condition) { 18 | this.condition = condition; 19 | } 20 | 21 | @Override 22 | public void accept(Context ctx) { 23 | ctx.visit(function(LIKELY, getDataType(), condition)); 24 | } 25 | } 26 | 27 | -------------------------------------------------------------------------------- /jooq-dialect/src/main/java/tech/ydb/jooq/dsl/function/builtin/MaxOf.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.jooq.dsl.function.builtin; 2 | 3 | import org.jooq.Context; 4 | import org.jooq.Field; 5 | import org.jooq.Name; 6 | import org.jooq.impl.AbstractYdbFunction; 7 | 8 | import static org.jooq.impl.DSL.function; 9 | import static org.jooq.impl.DSL.systemName; 10 | 11 | public final class MaxOf extends AbstractYdbFunction { 12 | 13 | private static final Name MAX_OF = systemName("max_of"); 14 | 15 | private final Field[] fields; 16 | 17 | public MaxOf(Field[] fields) { 18 | super( 19 | MAX_OF, 20 | fields[0].getDataType() 21 | ); 22 | 23 | this.fields = fields; 24 | } 25 | 26 | @Override 27 | public void accept(Context ctx) { 28 | ctx.visit(function(MAX_OF, getDataType(), fields)); 29 | } 30 | } 31 | 32 | -------------------------------------------------------------------------------- /jooq-dialect/src/main/java/tech/ydb/jooq/dsl/function/builtin/MinOf.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.jooq.dsl.function.builtin; 2 | 3 | import org.jooq.Context; 4 | import org.jooq.Field; 5 | import org.jooq.Name; 6 | import org.jooq.impl.AbstractYdbFunction; 7 | 8 | import static org.jooq.impl.DSL.function; 9 | import static org.jooq.impl.DSL.systemName; 10 | 11 | public final class MinOf extends AbstractYdbFunction { 12 | 13 | private static final Name MIN_OF = systemName("min_of"); 14 | 15 | private final Field[] fields; 16 | 17 | public MinOf(Field[] fields) { 18 | super( 19 | MIN_OF, 20 | fields[0].getDataType() 21 | ); 22 | 23 | this.fields = fields; 24 | } 25 | 26 | @Override 27 | public void accept(Context ctx) { 28 | ctx.visit(function(MIN_OF, getDataType(), fields)); 29 | } 30 | } 31 | 32 | -------------------------------------------------------------------------------- /jooq-dialect/src/main/java/tech/ydb/jooq/dsl/function/builtin/NaNvl.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.jooq.dsl.function.builtin; 2 | 3 | import org.jooq.Context; 4 | import org.jooq.Field; 5 | import org.jooq.Name; 6 | import org.jooq.impl.AbstractYdbFunction; 7 | 8 | import static org.jooq.impl.DSL.function; 9 | import static org.jooq.impl.DSL.systemName; 10 | 11 | public final class NaNvl extends AbstractYdbFunction { 12 | 13 | private static final Name NANVL = systemName("nanvl"); 14 | 15 | private final Field expression; 16 | private final Field replacement; 17 | 18 | public NaNvl(Field expression, Field replacement) { 19 | super( 20 | NANVL, 21 | expression.getDataType() 22 | ); 23 | 24 | this.expression = expression; 25 | this.replacement = replacement; 26 | } 27 | 28 | @Override 29 | public void accept(Context ctx) { 30 | ctx.visit(function(NANVL, getDataType(), expression, replacement)); 31 | } 32 | } -------------------------------------------------------------------------------- /jooq-dialect/src/main/java/tech/ydb/jooq/dsl/function/builtin/Nothing.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.jooq.dsl.function.builtin; 2 | 3 | import org.jooq.Context; 4 | import org.jooq.DataType; 5 | import org.jooq.Name; 6 | import org.jooq.impl.AbstractYdbFunction; 7 | 8 | import static org.jooq.impl.DSL.*; 9 | 10 | public final class Nothing extends AbstractYdbFunction { 11 | 12 | private static final Name NOTHING = systemName("Nothing"); 13 | 14 | private final DataType type; 15 | 16 | public Nothing(DataType type) { 17 | super( 18 | NOTHING, 19 | type 20 | ); 21 | 22 | this.type = type; 23 | } 24 | 25 | @Override 26 | public void accept(Context ctx) { 27 | ctx.visit(function(NOTHING, getDataType(), inline(type.getTypeName()))); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /jooq-dialect/src/main/java/tech/ydb/jooq/dsl/function/builtin/Pickle.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.jooq.dsl.function.builtin; 2 | 3 | import org.jooq.Context; 4 | import org.jooq.Field; 5 | import org.jooq.Name; 6 | import org.jooq.impl.AbstractYdbFunction; 7 | import tech.ydb.jooq.YdbTypes; 8 | 9 | import static org.jooq.impl.DSL.function; 10 | import static org.jooq.impl.DSL.systemName; 11 | 12 | public final class Pickle extends AbstractYdbFunction { 13 | 14 | private static final Name PICKLE = systemName("Pickle"); 15 | 16 | private final Field value; 17 | 18 | public Pickle(Field value) { 19 | super( 20 | PICKLE, 21 | YdbTypes.STRING 22 | ); 23 | 24 | this.value = value; 25 | } 26 | 27 | @Override 28 | public void accept(Context ctx) { 29 | ctx.visit(function(PICKLE, getDataType(), value)); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /jooq-dialect/src/main/java/tech/ydb/jooq/dsl/function/builtin/Random.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.jooq.dsl.function.builtin; 2 | 3 | import org.jooq.Context; 4 | import org.jooq.Field; 5 | import org.jooq.Name; 6 | import org.jooq.impl.AbstractYdbFunction; 7 | import tech.ydb.jooq.YdbTypes; 8 | 9 | import static org.jooq.impl.DSL.function; 10 | import static org.jooq.impl.DSL.systemName; 11 | 12 | public final class Random extends AbstractYdbFunction { 13 | 14 | private static final Name RANDOM = systemName("Random"); 15 | 16 | private final Field[] fields; 17 | 18 | public Random(Field[] fields) { 19 | super( 20 | RANDOM, 21 | YdbTypes.DOUBLE 22 | ); 23 | 24 | this.fields = fields; 25 | } 26 | 27 | @Override 28 | public void accept(Context ctx) { 29 | ctx.visit(function(RANDOM, getDataType(), fields)); 30 | } 31 | } 32 | 33 | -------------------------------------------------------------------------------- /jooq-dialect/src/main/java/tech/ydb/jooq/dsl/function/builtin/RandomNumber.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.jooq.dsl.function.builtin; 2 | 3 | import org.jooq.Context; 4 | import org.jooq.Field; 5 | import org.jooq.Name; 6 | import org.jooq.impl.AbstractYdbFunction; 7 | import org.jooq.types.ULong; 8 | import tech.ydb.jooq.YdbTypes; 9 | 10 | import static org.jooq.impl.DSL.function; 11 | import static org.jooq.impl.DSL.systemName; 12 | 13 | public final class RandomNumber extends AbstractYdbFunction { 14 | 15 | private static final Name RANDOM_NUMBER = systemName("RandomNumber"); 16 | 17 | private final Field[] fields; 18 | 19 | public RandomNumber(Field[] fields) { 20 | super( 21 | RANDOM_NUMBER, 22 | YdbTypes.UINT64 23 | ); 24 | 25 | this.fields = fields; 26 | } 27 | 28 | @Override 29 | public void accept(Context ctx) { 30 | ctx.visit(function(RANDOM_NUMBER, getDataType(), fields)); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /jooq-dialect/src/main/java/tech/ydb/jooq/dsl/function/builtin/RandomUuid.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.jooq.dsl.function.builtin; 2 | 3 | import org.jooq.Context; 4 | import org.jooq.Field; 5 | import org.jooq.Name; 6 | import org.jooq.impl.AbstractYdbFunction; 7 | import tech.ydb.jooq.YdbTypes; 8 | 9 | import java.util.UUID; 10 | 11 | import static org.jooq.impl.DSL.function; 12 | import static org.jooq.impl.DSL.systemName; 13 | 14 | public final class RandomUuid extends AbstractYdbFunction { 15 | 16 | private static final Name RANDOM_UUID = systemName("RandomUuid"); 17 | 18 | private final Field[] fields; 19 | 20 | public RandomUuid(Field[] fields) { 21 | super( 22 | RANDOM_UUID, 23 | YdbTypes.UUID 24 | ); 25 | 26 | this.fields = fields; 27 | } 28 | 29 | @Override 30 | public void accept(Context ctx) { 31 | ctx.visit(function(RANDOM_UUID, getDataType(), fields)); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /jooq-dialect/src/main/java/tech/ydb/jooq/dsl/function/builtin/RemoveTimezone.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.jooq.dsl.function.builtin; 2 | 3 | import org.jooq.Context; 4 | import org.jooq.DataType; 5 | import org.jooq.Field; 6 | import org.jooq.Name; 7 | import org.jooq.impl.AbstractYdbFunction; 8 | 9 | import static org.jooq.impl.DSL.function; 10 | import static org.jooq.impl.DSL.systemName; 11 | 12 | public final class RemoveTimezone extends AbstractYdbFunction { 13 | 14 | private static final Name REMOVE_TIMEZONE = systemName("RemoveTimezone"); 15 | 16 | private final Field date; 17 | 18 | public RemoveTimezone(Field date, DataType type) { 19 | super( 20 | REMOVE_TIMEZONE, 21 | type 22 | ); 23 | 24 | this.date = date; 25 | } 26 | 27 | @Override 28 | public void accept(Context ctx) { 29 | ctx.visit(function(REMOVE_TIMEZONE, getDataType(), date)); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /jooq-dialect/src/main/java/tech/ydb/jooq/dsl/function/builtin/SetBit.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.jooq.dsl.function.builtin; 2 | 3 | import org.jooq.Context; 4 | import org.jooq.Field; 5 | import org.jooq.Name; 6 | import org.jooq.impl.AbstractYdbFunction; 7 | import org.jooq.types.UByte; 8 | import org.jooq.types.UNumber; 9 | 10 | import static org.jooq.impl.DSL.function; 11 | import static org.jooq.impl.DSL.systemName; 12 | 13 | public final class SetBit extends AbstractYdbFunction { 14 | 15 | private static final Name SET_BIT = systemName("SetBit"); 16 | 17 | private final Field value; 18 | private final Field index; 19 | 20 | public SetBit(Field value, Field index) { 21 | super( 22 | SET_BIT, 23 | value.getDataType() 24 | ); 25 | 26 | this.value = value; 27 | this.index = index; 28 | } 29 | 30 | @Override 31 | public void accept(Context ctx) { 32 | ctx.visit(function(SET_BIT, getDataType(), value, index)); 33 | } 34 | } 35 | 36 | -------------------------------------------------------------------------------- /jooq-dialect/src/main/java/tech/ydb/jooq/dsl/function/builtin/StablePickle.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.jooq.dsl.function.builtin; 2 | 3 | import org.jooq.Context; 4 | import org.jooq.Field; 5 | import org.jooq.Name; 6 | import org.jooq.impl.AbstractYdbFunction; 7 | import tech.ydb.jooq.YdbTypes; 8 | 9 | import static org.jooq.impl.DSL.function; 10 | import static org.jooq.impl.DSL.systemName; 11 | 12 | public final class StablePickle extends AbstractYdbFunction { 13 | 14 | private static final Name STABLE_PICKLE = systemName("StablePickle"); 15 | 16 | private final Field value; 17 | 18 | public StablePickle(Field value) { 19 | super( 20 | STABLE_PICKLE, 21 | YdbTypes.STRING 22 | ); 23 | 24 | this.value = value; 25 | } 26 | 27 | @Override 28 | public void accept(Context ctx) { 29 | ctx.visit(function(STABLE_PICKLE, getDataType(), value)); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /jooq-dialect/src/main/java/tech/ydb/jooq/dsl/function/builtin/StartsWith.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.jooq.dsl.function.builtin; 2 | 3 | import org.jooq.Context; 4 | import org.jooq.Field; 5 | import org.jooq.Name; 6 | import org.jooq.impl.AbstractYdbCondition; 7 | 8 | import static org.jooq.impl.DSL.function; 9 | import static org.jooq.impl.DSL.systemName; 10 | 11 | public final class StartsWith extends AbstractYdbCondition { 12 | 13 | private static final Name STARTS_WITH = systemName("StartsWith"); 14 | 15 | private final Field source; 16 | private final Field substring; 17 | 18 | public StartsWith(Field source, Field substring) { 19 | this.source = source; 20 | this.substring = substring; 21 | } 22 | 23 | @Override 24 | public void accept(Context ctx) { 25 | ctx.visit(function(STARTS_WITH, getDataType(), source, substring)); 26 | } 27 | } -------------------------------------------------------------------------------- /jooq-dialect/src/main/java/tech/ydb/jooq/dsl/function/builtin/TestBit.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.jooq.dsl.function.builtin; 2 | 3 | import org.jooq.Context; 4 | import org.jooq.Field; 5 | import org.jooq.Name; 6 | import org.jooq.impl.AbstractYdbCondition; 7 | import org.jooq.types.UByte; 8 | import org.jooq.types.UNumber; 9 | 10 | import static org.jooq.impl.DSL.function; 11 | import static org.jooq.impl.DSL.systemName; 12 | 13 | public final class TestBit extends AbstractYdbCondition { 14 | 15 | private static final Name TEST_BIT = systemName("TestBit"); 16 | 17 | private final Field source; 18 | private final Field index; 19 | 20 | public TestBit(Field source, Field index) { 21 | this.source = source; 22 | this.index = index; 23 | } 24 | 25 | @Override 26 | public void accept(Context ctx) { 27 | ctx.visit(function(TEST_BIT, getDataType(), source, index)); 28 | } 29 | } -------------------------------------------------------------------------------- /jooq-dialect/src/main/java/tech/ydb/jooq/dsl/function/builtin/ToBytes.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.jooq.dsl.function.builtin; 2 | 3 | import org.jooq.Context; 4 | import org.jooq.Field; 5 | import org.jooq.Name; 6 | import org.jooq.impl.AbstractYdbFunction; 7 | import tech.ydb.jooq.YdbTypes; 8 | 9 | import static org.jooq.impl.DSL.function; 10 | import static org.jooq.impl.DSL.systemName; 11 | 12 | public final class ToBytes extends AbstractYdbFunction { 13 | 14 | private static final Name TO_BYTES = systemName("ToBytes"); 15 | 16 | private final Field value; 17 | 18 | public ToBytes(Field value) { 19 | super( 20 | TO_BYTES, 21 | YdbTypes.STRING 22 | ); 23 | 24 | this.value = value; 25 | } 26 | 27 | @Override 28 | public void accept(Context ctx) { 29 | ctx.visit(function(TO_BYTES, getDataType(), value)); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /jooq-dialect/src/main/java/tech/ydb/jooq/dsl/function/builtin/Unpickle.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.jooq.dsl.function.builtin; 2 | 3 | import org.jooq.Context; 4 | import org.jooq.DataType; 5 | import org.jooq.Field; 6 | import org.jooq.Name; 7 | import org.jooq.impl.AbstractYdbFunction; 8 | 9 | import static org.jooq.impl.DSL.*; 10 | 11 | public final class Unpickle extends AbstractYdbFunction { 12 | 13 | private static final Name UNPICKLE = systemName("Unpickle"); 14 | 15 | private final DataType type; 16 | private final Field bytes; 17 | 18 | public Unpickle(DataType type, Field bytes) { 19 | super( 20 | UNPICKLE, 21 | type 22 | ); 23 | 24 | this.type = type; 25 | this.bytes = bytes; 26 | } 27 | 28 | @Override 29 | public void accept(Context ctx) { 30 | ctx.visit(function(UNPICKLE, getDataType(), inline(type.getTypeName()), bytes)); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /jooq-dialect/src/main/java/tech/ydb/jooq/dsl/function/builtin/Unwrap.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.jooq.dsl.function.builtin; 2 | 3 | import org.jooq.Context; 4 | import org.jooq.Field; 5 | import org.jooq.Name; 6 | import org.jooq.impl.AbstractYdbFunction; 7 | 8 | import static org.jooq.impl.DSL.function; 9 | import static org.jooq.impl.DSL.systemName; 10 | 11 | public final class Unwrap extends AbstractYdbFunction { 12 | 13 | private static final Name UNWRAP = systemName("Unwrap"); 14 | 15 | private final Field value; 16 | private final Field message; 17 | 18 | public Unwrap(Field value, Field message) { 19 | super( 20 | UNWRAP, 21 | value.getDataType() 22 | ); 23 | 24 | this.value = value; 25 | this.message = message; 26 | } 27 | 28 | @Override 29 | public void accept(Context ctx) { 30 | if (message != null) { 31 | ctx.visit(function(UNWRAP, getDataType(), value, message)); 32 | } else { 33 | ctx.visit(function(UNWRAP, getDataType(), value)); 34 | } 35 | } 36 | } 37 | 38 | -------------------------------------------------------------------------------- /liquibase-dialect/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 1.1.1 ## 2 | 3 | * Read changesets from QueryService 4 | 5 | ## 1.1.0 ## 6 | 7 | * Supported UUID type in .xml, .yaml, and .json formats 8 | 9 | ## 1.0.2 ## 10 | 11 | * Added duration format for `Interval` type and ISO for time types when loading data into tables 12 | 13 | ## 1.0.1 ## 14 | 15 | * Scan select databasechangelog 16 | 17 | ## 1.0.0 ## 18 | 19 | * Fixed bug with distributed lock (setAutoCommit = false) 20 | * Supported insert changeset with all YDB types 21 | 22 | --- 23 | 24 | ## 0.9.7 ## 25 | 26 | * Supported NOT NULL statement 27 | * Added support for YDB unsigned integer types 28 | 29 | ## 0.9.6 ## 30 | 31 | * Fixed NullPointerException when load csv file 32 | 33 | ## 0.9.5 ## 34 | 35 | * Supported loadData and loadUpdateData from CSV file 36 | 37 | ## 0.9.4 ## 38 | 39 | * Change liquibase-parent-pom on liquibase-core dependency 40 | 41 | ## 0.9.3 ## 42 | 43 | * Shaded org.slf4j dependency from liquibase-parent-pom 44 | 45 | ## 0.9.2 ## 46 | 47 | * Fixed bug with NullPointerException in CREATE INDEX generator method 48 | 49 | ## 0.9.1 ## 50 | 51 | * Supported "CREATE TABLE", "ALTER TABLE", "DROP TABLE" and "CREATE INDEX" SQL statements from .xml, .json and .yaml file formats 52 | * Added support for YDB primitive data types 53 | * Included support for DATABASECHANGELOG and DATABASECHANGELOGLOCK tables -------------------------------------------------------------------------------- /liquibase-dialect/src/main/java/tech/ydb/liquibase/sqlgenerator/AddDefaultValueGeneratorYdb.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.liquibase.sqlgenerator; 2 | 3 | import liquibase.database.Database; 4 | import liquibase.exception.ValidationErrors; 5 | import liquibase.sqlgenerator.SqlGeneratorChain; 6 | import liquibase.statement.core.AddDefaultValueStatement; 7 | import tech.ydb.liquibase.exception.YdbMessageException; 8 | 9 | /** 10 | * @author Kirill Kurdyukov 11 | */ 12 | public class AddDefaultValueGeneratorYdb extends BaseSqlGeneratorYdb { 13 | 14 | @Override 15 | public ValidationErrors validate( 16 | AddDefaultValueStatement statement, 17 | Database database, 18 | SqlGeneratorChain sqlGeneratorChain 19 | ) { 20 | ValidationErrors validationErrors = new ValidationErrors(); 21 | 22 | validationErrors.addError(YdbMessageException.DOES_NOT_SUPPORT_DEFAULT_VALUE_CONSTRAINT + 23 | YdbMessageException.badTableStrPointer(statement::getTableName)); 24 | 25 | return validationErrors; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /liquibase-dialect/src/main/java/tech/ydb/liquibase/sqlgenerator/AddForeignKeyConstraintGeneratorYdb.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.liquibase.sqlgenerator; 2 | 3 | import liquibase.database.Database; 4 | import liquibase.exception.ValidationErrors; 5 | import liquibase.sqlgenerator.SqlGeneratorChain; 6 | import liquibase.statement.core.AddForeignKeyConstraintStatement; 7 | import tech.ydb.liquibase.exception.YdbMessageException; 8 | 9 | /** 10 | * @author Kirill Kurdyukov 11 | */ 12 | public class AddForeignKeyConstraintGeneratorYdb extends BaseSqlGeneratorYdb { 13 | 14 | @Override 15 | public ValidationErrors validate( 16 | AddForeignKeyConstraintStatement statement, 17 | Database database, 18 | SqlGeneratorChain sqlGeneratorChain 19 | ) { 20 | ValidationErrors validationErrors = new ValidationErrors(); 21 | 22 | validationErrors.addError(YdbMessageException.DOES_NOT_SUPPORT_FOREIGN_KEY_CONSTRAINT + 23 | YdbMessageException.badTableStrPointer(statement::getBaseTableName)); 24 | 25 | return validationErrors; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /liquibase-dialect/src/main/java/tech/ydb/liquibase/sqlgenerator/AddPrimaryKeyGeneratorYdb.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.liquibase.sqlgenerator; 2 | 3 | import liquibase.database.Database; 4 | import liquibase.exception.ValidationErrors; 5 | import liquibase.sqlgenerator.SqlGeneratorChain; 6 | import liquibase.statement.core.AddPrimaryKeyStatement; 7 | import tech.ydb.liquibase.exception.YdbMessageException; 8 | 9 | /** 10 | * @author Kirill Kurdyukov 11 | */ 12 | public class AddPrimaryKeyGeneratorYdb extends BaseSqlGeneratorYdb { 13 | 14 | @Override 15 | public ValidationErrors validate( 16 | AddPrimaryKeyStatement statement, 17 | Database database, 18 | SqlGeneratorChain sqlGeneratorChain 19 | ) { 20 | ValidationErrors validationErrors = new ValidationErrors(); 21 | 22 | validationErrors.addError(YdbMessageException.DOES_NOT_SUPPORT_PRIMARY_KEY_OUTSIDE_CREATE_TABLE + 23 | YdbMessageException.badTableStrPointer(statement::getTableName)); 24 | 25 | return validationErrors; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /liquibase-dialect/src/main/java/tech/ydb/liquibase/sqlgenerator/AddUniqueConstraintGeneratorYdb.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.liquibase.sqlgenerator; 2 | 3 | import liquibase.database.Database; 4 | import liquibase.exception.ValidationErrors; 5 | import liquibase.sqlgenerator.SqlGeneratorChain; 6 | import liquibase.statement.core.AddUniqueConstraintStatement; 7 | import tech.ydb.liquibase.exception.YdbMessageException; 8 | 9 | /** 10 | * @author Kirill Kurdyukov 11 | */ 12 | public class AddUniqueConstraintGeneratorYdb extends BaseSqlGeneratorYdb { 13 | 14 | @Override 15 | public ValidationErrors validate( 16 | AddUniqueConstraintStatement statement, 17 | Database database, 18 | SqlGeneratorChain sqlGeneratorChain 19 | ) { 20 | ValidationErrors validationErrors = new ValidationErrors(); 21 | 22 | validationErrors.addError(YdbMessageException.DOES_NOT_SUPPORT_UNIQUE_CONSTRAINT + 23 | YdbMessageException.badTableStrPointer(statement::getTableName)); 24 | 25 | return validationErrors; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /liquibase-dialect/src/main/java/tech/ydb/liquibase/sqlgenerator/BaseSqlGeneratorYdb.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.liquibase.sqlgenerator; 2 | 3 | import liquibase.database.Database; 4 | import liquibase.exception.ValidationErrors; 5 | import liquibase.sql.Sql; 6 | import liquibase.sqlgenerator.SqlGeneratorChain; 7 | import liquibase.sqlgenerator.core.AbstractSqlGenerator; 8 | import liquibase.statement.SqlStatement; 9 | import tech.ydb.liquibase.database.YdbDatabase; 10 | 11 | /** 12 | * @author Kirill Kurdyukov 13 | */ 14 | abstract class BaseSqlGeneratorYdb extends AbstractSqlGenerator { 15 | 16 | @Override 17 | public boolean supports(T statement, Database database) { 18 | return database instanceof YdbDatabase; 19 | } 20 | 21 | @Override 22 | public int getPriority() { 23 | return PRIORITY_DATABASE; 24 | } 25 | 26 | @Override 27 | public ValidationErrors validate(T statement, Database database, SqlGeneratorChain sqlGeneratorChain) { 28 | return new ValidationErrors(); 29 | } 30 | 31 | @Override 32 | public Sql[] generateSql(T statement, Database database, SqlGeneratorChain sqlGeneratorChain) { 33 | return new Sql[0]; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /liquibase-dialect/src/main/java/tech/ydb/liquibase/sqlgenerator/CreateProcedureGeneratorYdb.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.liquibase.sqlgenerator; 2 | 3 | import liquibase.database.Database; 4 | import liquibase.exception.ValidationErrors; 5 | import liquibase.sqlgenerator.SqlGeneratorChain; 6 | import liquibase.statement.core.CreateProcedureStatement; 7 | import tech.ydb.liquibase.exception.YdbMessageException; 8 | 9 | /** 10 | * @author Kirill Kurdyukov 11 | */ 12 | public class CreateProcedureGeneratorYdb extends BaseSqlGeneratorYdb { 13 | 14 | @Override 15 | public ValidationErrors validate( 16 | CreateProcedureStatement statement, 17 | Database database, 18 | SqlGeneratorChain sqlGeneratorChain 19 | ) { 20 | return YdbMessageException.ydbDoesNotSupportStatement(statement); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /liquibase-dialect/src/main/java/tech/ydb/liquibase/sqlgenerator/CreateViewGeneratorYdb.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.liquibase.sqlgenerator; 2 | 3 | import liquibase.database.Database; 4 | import liquibase.exception.ValidationErrors; 5 | import liquibase.sqlgenerator.SqlGeneratorChain; 6 | import liquibase.statement.core.CreateViewStatement; 7 | import tech.ydb.liquibase.exception.YdbMessageException; 8 | 9 | /** 10 | * @author Kirill Kurdyukov 11 | */ 12 | public class CreateViewGeneratorYdb extends BaseSqlGeneratorYdb { 13 | 14 | @Override 15 | public ValidationErrors validate( 16 | CreateViewStatement statement, 17 | Database database, 18 | SqlGeneratorChain sqlGeneratorChain 19 | ) { 20 | return YdbMessageException.ydbDoesNotSupportStatement(statement); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /liquibase-dialect/src/main/java/tech/ydb/liquibase/sqlgenerator/DropPrimaryKeyGeneratorSql.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.liquibase.sqlgenerator; 2 | 3 | import liquibase.database.Database; 4 | import liquibase.exception.ValidationErrors; 5 | import liquibase.sqlgenerator.SqlGeneratorChain; 6 | import liquibase.statement.core.DropPrimaryKeyStatement; 7 | import tech.ydb.liquibase.exception.YdbMessageException; 8 | 9 | /** 10 | * @author Kirill Kurdyukov 11 | */ 12 | public class DropPrimaryKeyGeneratorSql extends BaseSqlGeneratorYdb { 13 | 14 | @Override 15 | public ValidationErrors validate( 16 | DropPrimaryKeyStatement statement, 17 | Database database, 18 | SqlGeneratorChain sqlGeneratorChain 19 | ) { 20 | return YdbMessageException.ydbDoesNotSupportStatement(statement); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /liquibase-dialect/src/main/java/tech/ydb/liquibase/sqlgenerator/GetViewDefinitionGeneratorYdb.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.liquibase.sqlgenerator; 2 | 3 | import liquibase.database.Database; 4 | import liquibase.exception.ValidationErrors; 5 | import liquibase.sqlgenerator.SqlGeneratorChain; 6 | import liquibase.statement.core.GetViewDefinitionStatement; 7 | import tech.ydb.liquibase.exception.YdbMessageException; 8 | 9 | /** 10 | * @author Kirill Kurdyukov 11 | */ 12 | public class GetViewDefinitionGeneratorYdb extends BaseSqlGeneratorYdb { 13 | 14 | @Override 15 | public ValidationErrors validate( 16 | GetViewDefinitionStatement statement, 17 | Database database, 18 | SqlGeneratorChain sqlGeneratorChain 19 | ) { 20 | return YdbMessageException.ydbDoesNotSupportStatement(statement); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /liquibase-dialect/src/main/java/tech/ydb/liquibase/sqlgenerator/RenameColumnGeneratorYdb.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.liquibase.sqlgenerator; 2 | 3 | import liquibase.database.Database; 4 | import liquibase.exception.ValidationErrors; 5 | import liquibase.sqlgenerator.SqlGeneratorChain; 6 | import liquibase.statement.core.RenameColumnStatement; 7 | import tech.ydb.liquibase.exception.YdbMessageException; 8 | 9 | /** 10 | * @author Kirill Kurdyukov 11 | */ 12 | public class RenameColumnGeneratorYdb extends BaseSqlGeneratorYdb { 13 | 14 | @Override 15 | public ValidationErrors validate( 16 | RenameColumnStatement statement, 17 | Database database, 18 | SqlGeneratorChain sqlGeneratorChain 19 | ) { 20 | return YdbMessageException.ydbDoesNotSupportStatement(statement); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /liquibase-dialect/src/main/java/tech/ydb/liquibase/type/BaseTypeYdb.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.liquibase.type; 2 | 3 | import liquibase.change.core.LoadDataChange; 4 | import liquibase.database.Database; 5 | import liquibase.datatype.DatabaseDataType; 6 | import liquibase.datatype.LiquibaseDataType; 7 | import tech.ydb.liquibase.database.YdbDatabase; 8 | 9 | /** 10 | * @author Kirill Kurdyukov 11 | */ 12 | abstract class BaseTypeYdb extends LiquibaseDataType { 13 | 14 | @Override 15 | public boolean supports(Database database) { 16 | return database instanceof YdbDatabase; 17 | } 18 | 19 | @Override 20 | public DatabaseDataType toDatabaseDataType(Database database) { 21 | return new DatabaseDataType(getName().toUpperCase()); 22 | } 23 | 24 | protected String objectToSql(Object value) { 25 | return value.toString(); 26 | } 27 | 28 | @Override 29 | public String objectToSql(Object value, Database database) { 30 | if ((value == null) || "null".equalsIgnoreCase(value.toString())) { 31 | return "NULL"; 32 | } 33 | 34 | return objectToSql(value); 35 | } 36 | 37 | // un using 38 | @Override 39 | public LoadDataChange.LOAD_DATA_TYPE getLoadTypeName() { 40 | return LoadDataChange.LOAD_DATA_TYPE.OTHER; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /liquibase-dialect/src/main/java/tech/ydb/liquibase/type/BoolTypeYdb.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.liquibase.type; 2 | 3 | import liquibase.datatype.DataTypeInfo; 4 | import liquibase.datatype.LiquibaseDataType; 5 | 6 | /** 7 | * @author Kirill Kurdyukov 8 | */ 9 | @DataTypeInfo( 10 | name = "Bool", 11 | aliases = { 12 | "boolean", "java.sql.Types.BOOLEAN", 13 | "java.lang.Boolean", "bit", "bool", 14 | }, 15 | minParameters = 0, 16 | maxParameters = 0, 17 | priority = LiquibaseDataType.PRIORITY_DATABASE 18 | ) 19 | public class BoolTypeYdb extends BaseTypeYdb { 20 | } 21 | -------------------------------------------------------------------------------- /liquibase-dialect/src/main/java/tech/ydb/liquibase/type/BytesTypeYdb.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.liquibase.type; 2 | 3 | import liquibase.change.core.LoadDataChange; 4 | import liquibase.datatype.DataTypeInfo; 5 | import liquibase.datatype.LiquibaseDataType; 6 | 7 | /** 8 | * @author Kirill Kurdyukov 9 | */ 10 | @DataTypeInfo( 11 | name = "Bytes", 12 | aliases = { 13 | "blob", "longblob", "longvarbinary", "String", 14 | "java.sql.Types.BLOB", "java.sql.Types.LONGBLOB", 15 | "java.sql.Types.LONGVARBINARY", "java.sql.Types.VARBINARY", 16 | "java.sql.Types.BINARY", "varbinary", "binary", "image", 17 | "tinyblob", "mediumblob", "long binary", "long varbinary" 18 | }, 19 | minParameters = 0, 20 | maxParameters = 0, 21 | priority = LiquibaseDataType.PRIORITY_DATABASE 22 | ) 23 | public class BytesTypeYdb extends BaseTypeYdb { 24 | 25 | @Override 26 | public LoadDataChange.LOAD_DATA_TYPE getLoadTypeName() { 27 | return LoadDataChange.LOAD_DATA_TYPE.BLOB; 28 | } 29 | 30 | @Override 31 | protected String objectToSql(Object value) { 32 | return "'" + value + "'"; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /liquibase-dialect/src/main/java/tech/ydb/liquibase/type/DateTypeYdb.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.liquibase.type; 2 | 3 | import java.time.LocalDate; 4 | import liquibase.datatype.DataTypeInfo; 5 | import liquibase.datatype.LiquibaseDataType; 6 | 7 | /** 8 | * @author Kirill Kurdyukov 9 | */ 10 | @DataTypeInfo( 11 | name = "Date", 12 | minParameters = 0, 13 | maxParameters = 0, 14 | aliases = {"java.sql.Types.DATE", "smalldatetime"}, 15 | priority = LiquibaseDataType.PRIORITY_DATABASE 16 | ) 17 | public class DateTypeYdb extends BaseTypeYdb { 18 | 19 | @Override 20 | protected String objectToSql(Object value) { 21 | return "DATE('" + LocalDate.parse(value.toString()) + "')"; 22 | } 23 | } -------------------------------------------------------------------------------- /liquibase-dialect/src/main/java/tech/ydb/liquibase/type/DecimalTypeYdb.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.liquibase.type; 2 | 3 | import liquibase.database.Database; 4 | import liquibase.datatype.DataTypeInfo; 5 | import liquibase.datatype.DatabaseDataType; 6 | import liquibase.datatype.LiquibaseDataType; 7 | 8 | /** 9 | * @author Kirill Kurdyukov 10 | */ 11 | @DataTypeInfo( 12 | name = "Decimal", 13 | aliases = {"java.sql.Types.DECIMAL", "java.math.BigDecimal"}, 14 | minParameters = 2, 15 | maxParameters = 2, 16 | priority = LiquibaseDataType.PRIORITY_DATABASE 17 | ) 18 | public class DecimalTypeYdb extends BaseTypeYdb { 19 | 20 | @Override 21 | public boolean validate(Database database) { 22 | return super.validate(database) && 23 | getParameters()[0].equals(22) && getParameters()[1].equals(9); // Fixed Decimal(22,9) 24 | } 25 | 26 | @Override 27 | public DatabaseDataType toDatabaseDataType(Database database) { 28 | return new DatabaseDataType("DECIMAL(22,9)"); 29 | } 30 | 31 | @Override 32 | protected String objectToSql(Object value) { 33 | return "CAST('" + value + "' AS DECIMAL(22,9))"; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /liquibase-dialect/src/main/java/tech/ydb/liquibase/type/DoubleTypeYdb.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.liquibase.type; 2 | 3 | import liquibase.datatype.DataTypeInfo; 4 | import liquibase.datatype.LiquibaseDataType; 5 | 6 | /** 7 | * @author Kirill Kurdyukov 8 | */ 9 | @DataTypeInfo( 10 | name = "Double", 11 | aliases = {"java.sql.Types.DOUBLE", "java.lang.Double"}, 12 | minParameters = 0, 13 | maxParameters = 0, 14 | priority = LiquibaseDataType.PRIORITY_DATABASE 15 | ) 16 | public class DoubleTypeYdb extends BaseTypeYdb { 17 | } 18 | -------------------------------------------------------------------------------- /liquibase-dialect/src/main/java/tech/ydb/liquibase/type/FloatTypeYdb.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.liquibase.type; 2 | 3 | import liquibase.datatype.DataTypeInfo; 4 | import liquibase.datatype.LiquibaseDataType; 5 | 6 | /** 7 | * @author Kirill Kurdyukov 8 | */ 9 | @DataTypeInfo( 10 | name = "Float", 11 | aliases = {"java.sql.Types.FLOAT", "java.lang.Float", "real", "java.sql.Types.REAL"}, 12 | minParameters = 0, 13 | maxParameters = 0, 14 | priority = LiquibaseDataType.PRIORITY_DATABASE 15 | ) 16 | 17 | public class FloatTypeYdb extends BaseTypeYdb { 18 | 19 | @Override 20 | protected String objectToSql(Object value) { 21 | return "CAST('" + value + "' AS FLOAT)"; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /liquibase-dialect/src/main/java/tech/ydb/liquibase/type/IntTypeYdb.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.liquibase.type; 2 | 3 | import liquibase.datatype.DataTypeInfo; 4 | import liquibase.datatype.LiquibaseDataType; 5 | 6 | /** 7 | * @author Kirill Kurdyukov 8 | */ 9 | @DataTypeInfo( 10 | name = "Int32", 11 | aliases = {"int", "integer", "java.sql.Types.INTEGER", "java.lang.Integer", "int4"}, 12 | minParameters = 0, 13 | maxParameters = 0, 14 | priority = LiquibaseDataType.PRIORITY_DATABASE 15 | ) 16 | public class IntTypeYdb extends BaseTypeYdb { 17 | } 18 | -------------------------------------------------------------------------------- /liquibase-dialect/src/main/java/tech/ydb/liquibase/type/IntervalTypeYdb.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.liquibase.type; 2 | 3 | import java.time.Duration; 4 | import java.util.concurrent.TimeUnit; 5 | import liquibase.datatype.DataTypeInfo; 6 | import liquibase.datatype.LiquibaseDataType; 7 | 8 | /** 9 | * @author Kirill Kurdyukov 10 | */ 11 | @DataTypeInfo( 12 | name = "Interval", 13 | minParameters = 0, 14 | maxParameters = 0, 15 | priority = LiquibaseDataType.PRIORITY_DATABASE 16 | ) 17 | public class IntervalTypeYdb extends BaseTypeYdb { 18 | 19 | @Override 20 | public String objectToSql(Object value) { 21 | Duration interval = Duration.parse(value.toString()); 22 | 23 | return "CAST(" + TimeUnit.NANOSECONDS.toMicros(interval.toNanos()) + " AS INTERVAL)"; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /liquibase-dialect/src/main/java/tech/ydb/liquibase/type/JsonDocumentTypeYdb.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.liquibase.type; 2 | 3 | import liquibase.datatype.DataTypeInfo; 4 | import liquibase.datatype.LiquibaseDataType; 5 | 6 | /** 7 | * @author Kirill Kurdyukov 8 | */ 9 | @DataTypeInfo( 10 | name = "JsonDocument", 11 | minParameters = 0, 12 | maxParameters = 0, 13 | priority = LiquibaseDataType.PRIORITY_DATABASE 14 | ) 15 | public class JsonDocumentTypeYdb extends BaseTypeYdb { 16 | 17 | @Override 18 | protected String objectToSql(Object value) { 19 | return "CAST('" + value + "' AS JSONDOCUMENT)"; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /liquibase-dialect/src/main/java/tech/ydb/liquibase/type/JsonTypeYdb.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.liquibase.type; 2 | 3 | import liquibase.datatype.DataTypeInfo; 4 | import liquibase.datatype.LiquibaseDataType; 5 | 6 | /** 7 | * @author Kirill Kurdyukov 8 | */ 9 | @DataTypeInfo( 10 | name = "Json", 11 | minParameters = 0, 12 | maxParameters = 0, 13 | priority = LiquibaseDataType.PRIORITY_DATABASE 14 | ) 15 | public class JsonTypeYdb extends BaseTypeYdb { 16 | 17 | @Override 18 | protected String objectToSql(Object value) { 19 | return "CAST('" + value + "' AS JSON)"; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /liquibase-dialect/src/main/java/tech/ydb/liquibase/type/LongTypeYdb.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.liquibase.type; 2 | 3 | import liquibase.datatype.DataTypeInfo; 4 | import liquibase.datatype.LiquibaseDataType; 5 | 6 | /** 7 | * @author Kirill Kurdyukov 8 | */ 9 | @DataTypeInfo( 10 | name = "Int64", 11 | aliases = { 12 | "bigint", "java.sql.Types.BIGINT", 13 | "java.math.BigInteger", "java.lang.Long", 14 | "integer8", "bigserial", "long", 15 | }, 16 | minParameters = 0, 17 | maxParameters = 0, 18 | priority = LiquibaseDataType.PRIORITY_DATABASE 19 | ) 20 | public class LongTypeYdb extends BaseTypeYdb { 21 | } 22 | -------------------------------------------------------------------------------- /liquibase-dialect/src/main/java/tech/ydb/liquibase/type/SmallIntTypeYdb.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.liquibase.type; 2 | 3 | import liquibase.datatype.DataTypeInfo; 4 | import liquibase.datatype.LiquibaseDataType; 5 | 6 | /** 7 | * @author Kirill Kurdyukov 8 | */ 9 | @DataTypeInfo( 10 | name = "Int16", 11 | aliases = {"java.sql.Types.SMALLINT", "int2", "smallserial", "smallint"}, 12 | minParameters = 0, 13 | maxParameters = 0, 14 | priority = LiquibaseDataType.PRIORITY_DATABASE 15 | ) 16 | public class SmallIntTypeYdb extends BaseTypeYdb { 17 | } 18 | -------------------------------------------------------------------------------- /liquibase-dialect/src/main/java/tech/ydb/liquibase/type/TimestampTypeYdb.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.liquibase.type; 2 | 3 | import java.sql.Timestamp; 4 | import java.time.Instant; 5 | import liquibase.datatype.DataTypeInfo; 6 | import liquibase.datatype.LiquibaseDataType; 7 | 8 | /** 9 | * @author Kirill Kurdyukov 10 | */ 11 | @DataTypeInfo( 12 | name = "Timestamp", 13 | aliases = {"java.sql.Types.TIMESTAMP", "java.sql.TIMESTAMP"}, 14 | minParameters = 0, 15 | maxParameters = 0, 16 | priority = LiquibaseDataType.PRIORITY_DATABASE 17 | ) 18 | public class TimestampTypeYdb extends BaseTypeYdb { 19 | 20 | @Override 21 | protected String objectToSql(Object value) { 22 | if (value instanceof Timestamp) { 23 | return "TIMESTAMP('" + ((Timestamp) value).toInstant() + "')"; 24 | } 25 | 26 | return "TIMESTAMP('" + Instant.parse(value.toString()) + "')"; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /liquibase-dialect/src/main/java/tech/ydb/liquibase/type/TinyIntTypeYdb.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.liquibase.type; 2 | 3 | import liquibase.datatype.DataTypeInfo; 4 | import liquibase.datatype.LiquibaseDataType; 5 | 6 | /** 7 | * @author Kirill Kurdyukov 8 | */ 9 | @DataTypeInfo( 10 | name = "Int8", 11 | aliases = {"java.sql.Types.TINYINT", "tinyint"}, 12 | minParameters = 0, 13 | maxParameters = 0, 14 | priority = LiquibaseDataType.PRIORITY_DATABASE 15 | ) 16 | public class TinyIntTypeYdb extends BaseTypeYdb { 17 | } 18 | -------------------------------------------------------------------------------- /liquibase-dialect/src/main/java/tech/ydb/liquibase/type/Uint16TypeYdb.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.liquibase.type; 2 | 3 | import liquibase.datatype.DataTypeInfo; 4 | import liquibase.datatype.LiquibaseDataType; 5 | 6 | /** 7 | * @author Kirill Kurdyukov 8 | */ 9 | @DataTypeInfo( 10 | name = "Uint16", 11 | minParameters = 0, 12 | maxParameters = 0, 13 | priority = LiquibaseDataType.PRIORITY_DATABASE 14 | ) 15 | public class Uint16TypeYdb extends BaseTypeYdb { 16 | } 17 | -------------------------------------------------------------------------------- /liquibase-dialect/src/main/java/tech/ydb/liquibase/type/Uint32TypeYdb.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.liquibase.type; 2 | 3 | import liquibase.datatype.DataTypeInfo; 4 | import liquibase.datatype.LiquibaseDataType; 5 | 6 | /** 7 | * @author Kirill Kurdyukov 8 | */ 9 | @DataTypeInfo( 10 | name = "Uint32", 11 | minParameters = 0, 12 | maxParameters = 0, 13 | priority = LiquibaseDataType.PRIORITY_DATABASE 14 | ) 15 | public class Uint32TypeYdb extends BaseTypeYdb { 16 | } 17 | -------------------------------------------------------------------------------- /liquibase-dialect/src/main/java/tech/ydb/liquibase/type/Uint64TypeYdb.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.liquibase.type; 2 | 3 | import liquibase.datatype.DataTypeInfo; 4 | import liquibase.datatype.LiquibaseDataType; 5 | 6 | /** 7 | * @author Kirill Kurdyukov 8 | */ 9 | @DataTypeInfo( 10 | name = "Uint64", 11 | minParameters = 0, 12 | maxParameters = 0, 13 | priority = LiquibaseDataType.PRIORITY_DATABASE 14 | ) 15 | public class Uint64TypeYdb extends BaseTypeYdb { 16 | } 17 | -------------------------------------------------------------------------------- /liquibase-dialect/src/main/java/tech/ydb/liquibase/type/Uint8TypeYdb.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.liquibase.type; 2 | 3 | import liquibase.datatype.DataTypeInfo; 4 | import liquibase.datatype.LiquibaseDataType; 5 | 6 | /** 7 | * @author Kirill Kurdyukov 8 | */ 9 | @DataTypeInfo( 10 | name = "Uint8", 11 | minParameters = 0, 12 | maxParameters = 0, 13 | priority = LiquibaseDataType.PRIORITY_DATABASE 14 | ) 15 | public class Uint8TypeYdb extends BaseTypeYdb { 16 | } 17 | -------------------------------------------------------------------------------- /liquibase-dialect/src/main/java/tech/ydb/liquibase/type/UuidTypeYdb.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.liquibase.type; 2 | 3 | import liquibase.change.core.LoadDataChange; 4 | import liquibase.datatype.DataTypeInfo; 5 | import liquibase.datatype.LiquibaseDataType; 6 | 7 | /** 8 | * @author Kirill Kurdyukov 9 | */ 10 | @DataTypeInfo( 11 | name = "UUID", 12 | aliases = {"uniqueidentifier", "java.util.UUID"}, 13 | minParameters = 0, 14 | maxParameters = 0, 15 | priority = LiquibaseDataType.PRIORITY_DATABASE 16 | ) 17 | public class UuidTypeYdb extends BaseTypeYdb { 18 | 19 | @Override 20 | public LoadDataChange.LOAD_DATA_TYPE getLoadTypeName() { 21 | return LoadDataChange.LOAD_DATA_TYPE.UUID; 22 | } 23 | 24 | @Override 25 | protected String objectToSql(Object value) { 26 | return "Uuid('" + value + "')"; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /liquibase-dialect/src/main/resources/META-INF/services/liquibase.change.Change: -------------------------------------------------------------------------------- 1 | tech.ydb.liquibase.change.InsertDataChangeYdb 2 | tech.ydb.liquibase.change.LoadDataChangeYdb 3 | tech.ydb.liquibase.change.LoadUpdateDataChangeYdb 4 | -------------------------------------------------------------------------------- /liquibase-dialect/src/main/resources/META-INF/services/liquibase.database.Database: -------------------------------------------------------------------------------- 1 | tech.ydb.liquibase.database.YdbDatabase -------------------------------------------------------------------------------- /liquibase-dialect/src/main/resources/META-INF/services/liquibase.datatype.LiquibaseDataType: -------------------------------------------------------------------------------- 1 | tech.ydb.liquibase.type.BoolTypeYdb 2 | tech.ydb.liquibase.type.BytesTypeYdb 3 | tech.ydb.liquibase.type.DateTypeYdb 4 | tech.ydb.liquibase.type.DecimalTypeYdb 5 | tech.ydb.liquibase.type.DoubleTypeYdb 6 | tech.ydb.liquibase.type.FloatTypeYdb 7 | tech.ydb.liquibase.type.IntervalTypeYdb 8 | tech.ydb.liquibase.type.IntTypeYdb 9 | tech.ydb.liquibase.type.JsonDocumentTypeYdb 10 | tech.ydb.liquibase.type.JsonTypeYdb 11 | tech.ydb.liquibase.type.LongTypeYdb 12 | tech.ydb.liquibase.type.SmallIntTypeYdb 13 | tech.ydb.liquibase.type.TextTypeYdb 14 | tech.ydb.liquibase.type.TimestampTypeYdb 15 | tech.ydb.liquibase.type.TimeTypeYdb 16 | tech.ydb.liquibase.type.TinyIntTypeYdb 17 | tech.ydb.liquibase.type.Uint8TypeYdb 18 | tech.ydb.liquibase.type.Uint16TypeYdb 19 | tech.ydb.liquibase.type.Uint32TypeYdb 20 | tech.ydb.liquibase.type.Uint64TypeYdb 21 | tech.ydb.liquibase.type.UuidTypeYdb -------------------------------------------------------------------------------- /liquibase-dialect/src/main/resources/META-INF/services/liquibase.lockservice.LockService: -------------------------------------------------------------------------------- 1 | tech.ydb.liquibase.lockservice.StandardLockServiceYdb -------------------------------------------------------------------------------- /liquibase-dialect/src/main/resources/META-INF/services/liquibase.snapshot.SnapshotGenerator: -------------------------------------------------------------------------------- 1 | tech.ydb.liquibase.snapshot.UniqueConstraintSnapshotGeneratorYdb -------------------------------------------------------------------------------- /liquibase-dialect/src/main/resources/META-INF/services/liquibase.sqlgenerator.SqlGenerator: -------------------------------------------------------------------------------- 1 | tech.ydb.liquibase.sqlgenerator.AddColumnGeneratorYdb 2 | tech.ydb.liquibase.sqlgenerator.AddDefaultValueGeneratorYdb 3 | tech.ydb.liquibase.sqlgenerator.AddForeignKeyConstraintGeneratorYdb 4 | tech.ydb.liquibase.sqlgenerator.AddPrimaryKeyGeneratorYdb 5 | tech.ydb.liquibase.sqlgenerator.AddUniqueConstraintGeneratorYdb 6 | tech.ydb.liquibase.sqlgenerator.CreateDatabaseChangeLogLockTableGeneratorYdb 7 | tech.ydb.liquibase.sqlgenerator.CreateDatabaseChangeLogTableGeneratorYdb 8 | tech.ydb.liquibase.sqlgenerator.CreateIndexGeneratorYdb 9 | tech.ydb.liquibase.sqlgenerator.CreateProcedureGeneratorYdb 10 | tech.ydb.liquibase.sqlgenerator.CreateTableGeneratorYdb 11 | tech.ydb.liquibase.sqlgenerator.CreateViewGeneratorYdb 12 | tech.ydb.liquibase.sqlgenerator.DropIndexGeneratorYdb 13 | tech.ydb.liquibase.sqlgenerator.DropPrimaryKeyGeneratorSql 14 | tech.ydb.liquibase.sqlgenerator.GetViewDefinitionGeneratorYdb 15 | tech.ydb.liquibase.sqlgenerator.InsertOrUpdateGeneratorYdb 16 | tech.ydb.liquibase.sqlgenerator.RenameColumnGeneratorYdb 17 | tech.ydb.liquibase.sqlgenerator.RenameTableGeneratorYdb -------------------------------------------------------------------------------- /liquibase-dialect/src/test/resources/changelogs/changelog-init.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | -------------------------------------------------------------------------------- /liquibase-dialect/src/test/resources/changelogs/changelog-load-csv.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /liquibase-dialect/src/test/resources/changelogs/changelog-step-1.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /liquibase-dialect/src/test/resources/changelogs/changelog-step-2.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /liquibase-dialect/src/test/resources/changelogs/changelog-step-3.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /liquibase-dialect/src/test/resources/changelogs/changelog_batch_load_data.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /liquibase-dialect/src/test/resources/changelogs/csv/test-insert.csv: -------------------------------------------------------------------------------- 1 | id,bool_column,bigint_column,smallint_column,tinyint_column,float_column,double_column,decimal_column,uint8_column,uint16_column,uint32_column,uint64_column,text_column,binary_column,json_column,jsondocument_column,date_column,datetime_column,timestamp_column,interval_column,uuid_column 2 | 2,true,123123,13000,112,1.123,1.123123,1.123123,12,13,14,15,Кирилл Курдюков Алексеевич,binary,{"asd": "asd"},{"asd": "asd"},2014-04-06,2023-09-16T12:30,2023-07-31T17:00:00.000000Z,PT10S,689fd2b6-5764-4c43-8803-519da8f5f305 3 | 3,true,123123,13000,112,1.123,1.123123,1.123123,12,13,14,15,Кирилл Курдюков Алексеевич,binary,{"asd": "asd"},{"asd": "asd"},2014-04-06,2023-09-16T12:30,2023-07-31T17:00:00.000000Z,PT10S,689fd2b6-5764-4c43-8803-519da8f5f305 4 | 6,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null -------------------------------------------------------------------------------- /liquibase-dialect/src/test/resources/changelogs/csv/test-upsert.csv: -------------------------------------------------------------------------------- 1 | id,bool_column,bigint_column,smallint_column,tinyint_column,float_column,double_column,decimal_column,uint8_column,uint16_column,uint32_column,uint64_column,text_column,binary_column,json_column,jsondocument_column,date_column,datetime_column,timestamp_column,interval_column,uuid_column 2 | 1,true,123123,13000,113,1.123,1.123123,1.123123,12,13,14,15,Кирилл Курдюков Алексеевич,binary,{"asd": "asd"},{"asd": "asd"},2014-04-06,2023-09-16T12:30,2023-07-31T17:00:00.000000Z,PT10S,689fd2b6-5764-4c43-8803-519da8f5f305 3 | 5,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null -------------------------------------------------------------------------------- /liquibase-dialect/src/test/resources/changelogs/migration-fail/table_has_auto_increment.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | Table without primary key. 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /liquibase-dialect/src/test/resources/changelogs/migration-fail/table_has_default_value.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | Table without primary key. 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /liquibase-dialect/src/test/resources/changelogs/migration-fail/table_has_foreign_key.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | Table without primary key. 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /liquibase-dialect/src/test/resources/changelogs/migration-fail/table_has_unique_constraint.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | Table without primary key. 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /liquibase-dialect/src/test/resources/changelogs/migration-fail/table_not_has_primary_key.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | Table without primary key. 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /liquibase-dialect/src/test/resources/changelogs/migration/alter_table.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | Alter table episodes. 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /liquibase-dialect/src/test/resources/changelogs/migration/series.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | Table series. 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /liquibase-dialect/src/test/resources/changelogs/update/changelog-step-1.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /liquibase-dialect/src/test/resources/changelogs/update/changelog-step-2.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /liquibase-dialect/src/test/resources/changelogs/update/create-table.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | create table test( 11 | id Int32 NOT NULL, 12 | code Text NOT NULL, 13 | token bool, 14 | PRIMARY KEY (id) 15 | ); 16 | 17 | 18 | drop table test; 19 | 20 | 21 | -------------------------------------------------------------------------------- /liquibase-dialect/src/test/resources/changelogs/update/insert.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | insert into test(id, code, token) 11 | values (1, 'A', null), 12 | (2, 'A', null), 13 | (3, 'A', null), 14 | (4, 'B', true); 15 | 16 | 17 | -------------------------------------------------------------------------------- /liquibase-dialect/src/test/resources/changelogs/update/update.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | update test 11 | set token= true 12 | where code = 'A'; 13 | 14 | 15 | update test set token=NULL where code='A'; 16 | 17 | 18 | -------------------------------------------------------------------------------- /liquibase-dialect/src/test/resources/liquibase.properties: -------------------------------------------------------------------------------- 1 | changelog-file=changelogs/changelog-load-csv.xml 2 | url=jdbc:ydb:grpc://localhost:2136/local 3 | -------------------------------------------------------------------------------- /liquibase-dialect/src/test/resources/logging.properties: -------------------------------------------------------------------------------- 1 | handlers= java.util.logging.ConsoleHandler 2 | .level=DEBUG 3 | java.util.logging.ConsoleHandler.level = ALL 4 | java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter 5 | java.util.logging.SimpleFormatter.format= %1$tF %1$tT [%4$s] %3$s %5$s %n 6 | 7 | tech.ydb.jdbc.level=ALL 8 | #tech.ydb.level=FINEST 9 | -------------------------------------------------------------------------------- /liquibase-dialect/stress-test/README.md: -------------------------------------------------------------------------------- 1 | # Stress test YDB Dialect Liquibase 2 | 3 | The test checks the distributed lock that Liquibase uses to ensure consistent migration application. 4 | -------------------------------------------------------------------------------- /liquibase-dialect/stress-test/changelog/changelog-0.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | -------------------------------------------------------------------------------- /liquibase-dialect/stress-test/changelog/changelog-1.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /liquibase-dialect/stress-test/changelog/changelog-2.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /liquibase-dialect/stress-test/changelog/changelog-3.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /liquibase-dialect/stress-test/changelog/changelog-4.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /liquibase-dialect/stress-test/changelog/changelog-5.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /liquibase-dialect/stress-test/changelog/changelog-6.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /liquibase-dialect/stress-test/changelog/csv/episodes.csv: -------------------------------------------------------------------------------- 1 | series_id,season_id,episode_id,title,air_date 2 | 1,1,1,"Yesterday'sJam",2006-02-03T10:00:00Z 3 | 1,1,2,"CalamityJen",2006-02-03T10:00:00Z 4 | 1,1,3,"Fifty-Fifty",2006-02-10T10:00:00Z 5 | 1,1,4,"TheRedDoor",2006-02-17T10:00:00Z 6 | 1,1,5,"TheHauntingofBillCrouse",2006-02-24T10:00:00Z 7 | 1,1,6,"AuntIrmaVisits",2006-03-03T10:00:00Z 8 | 1,2,1,"TheWorkOuting",2006-08-24T10:00:00Z 9 | 1,2,2,"ReturnoftheGoldenChild",2007-08-31T10:00:00Z 10 | 1,2,3,"MossandtheGerman",2007-09-07T10:00:00Z 11 | 1,2,4,"TheDinnerParty",2007-09-14T10:00:00Z 12 | -------------------------------------------------------------------------------- /liquibase-dialect/stress-test/changelog/migration/add-column-episodes.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /liquibase-dialect/stress-test/changelog/migration/create-index-episodes.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /liquibase-dialect/stress-test/changelog/migration/episodes.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | Table episodes. 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /liquibase-dialect/stress-test/changelog/migration/load-csv-to-episodes.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /liquibase-dialect/stress-test/changelog/migration/rename-table-episodes.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /liquibase-dialect/stress-test/go.mod: -------------------------------------------------------------------------------- 1 | module stress-test 2 | 3 | go 1.22rc1 4 | 5 | require ( 6 | github.com/stretchr/testify v1.7.1 7 | github.com/ydb-platform/ydb-go-sdk/v3 v3.61.0 8 | ) 9 | 10 | require ( 11 | github.com/davecgh/go-spew v1.1.0 // indirect 12 | github.com/golang-jwt/jwt/v4 v4.5.0 // indirect 13 | github.com/golang/protobuf v1.5.4 // indirect 14 | github.com/google/uuid v1.6.0 // indirect 15 | github.com/jonboulle/clockwork v0.4.0 // indirect 16 | github.com/pmezard/go-difflib v1.0.0 // indirect 17 | github.com/ydb-platform/ydb-go-genproto v0.0.0-20240316140903-4a47abca1cca // indirect 18 | golang.org/x/net v0.22.0 // indirect 19 | golang.org/x/sync v0.6.0 // indirect 20 | golang.org/x/sys v0.18.0 // indirect 21 | golang.org/x/text v0.14.0 // indirect 22 | google.golang.org/genproto/googleapis/rpc v0.0.0-20240325203815-454cdb8f5daa // indirect 23 | google.golang.org/grpc v1.62.1 // indirect 24 | google.golang.org/protobuf v1.33.0 // indirect 25 | gopkg.in/yaml.v3 v3.0.0 // indirect 26 | ) 27 | -------------------------------------------------------------------------------- /liquibase-dialect/stress-test/liquibase.properties: -------------------------------------------------------------------------------- 1 | url=jdbc:ydb:grpc://localhost:2136/local 2 | changelog-file=changelog/changelog-2.xml 3 | -------------------------------------------------------------------------------- /liquibase-dialect/stress-test/run.sh: -------------------------------------------------------------------------------- 1 | YDB_JDBC_DRIVER_VERSION=2.3.6 2 | 3 | echo Stress test using ydb-jdbc-driver-shaded:"$YDB_JDBC_DRIVER_VERSION" 4 | 5 | curl -L -o ydb-jdbc-driver.jar https://repo1.maven.org/maven2/tech/ydb/jdbc/ydb-jdbc-driver-shaded/$YDB_JDBC_DRIVER_VERSION/ydb-jdbc-driver-shaded-$YDB_JDBC_DRIVER_VERSION.jar 6 | 7 | cd .. 8 | mvn clean package -DskipTests=true 9 | 10 | LIQUIBASE_DIALECT_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout) 11 | 12 | LIQUIBASE_CORE_VERSION=$(mvn help:evaluate -Dexpression=liquibase.core.version -q -DforceStdout) 13 | 14 | cd stress-test 15 | 16 | echo Stress test using liquibase-ydb-dialect:"$LIQUIBASE_DIALECT_VERSION" 17 | 18 | echo Stress test using liquibase-core:"$LIQUIBASE_CORE_VERSION" 19 | 20 | cp ../target/liquibase-ydb-dialect-"$LIQUIBASE_DIALECT_VERSION".jar ./liquibase-ydb-dialect.jar 21 | 22 | mkdir liquibase-cli 23 | cd liquibase-cli 24 | 25 | curl -L "https://github.com/liquibase/liquibase/releases/download/v$LIQUIBASE_CORE_VERSION/liquibase-$LIQUIBASE_CORE_VERSION.zip" -o liquibase.zip 26 | 27 | unzip liquibase.zip 28 | 29 | cd .. 30 | 31 | cp liquibase-ydb-dialect.jar ./liquibase-cli/internal/lib/ 32 | cp ydb-jdbc-driver.jar ./liquibase-cli/internal/lib/ 33 | 34 | echo Start Go test 35 | 36 | go test 37 | 38 | rm -rf liquibase-cli 39 | -------------------------------------------------------------------------------- /shedlock-ydb/src/main/java/tech/ydb/lock/provider/YdbLockProviderConfiguration.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.lock.provider; 2 | 3 | import javax.sql.DataSource; 4 | import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.context.annotation.Configuration; 7 | 8 | /** 9 | * @author Kirill Kurdyukov 10 | */ 11 | 12 | @Configuration 13 | public class YdbLockProviderConfiguration { 14 | @Bean 15 | @ConditionalOnBean(DataSource.class) 16 | public YdbJDBCLockProvider ydbLockProvider(DataSource dataSource) { 17 | return new YdbJDBCLockProvider(dataSource); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /shedlock-ydb/src/main/java/tech/ydb/lock/provider/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * @author Kirill Kurdyukov 3 | */ 4 | @NonNullApi 5 | package tech.ydb.lock.provider; 6 | 7 | import org.springframework.lang.NonNullApi; -------------------------------------------------------------------------------- /shedlock-ydb/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports: -------------------------------------------------------------------------------- 1 | tech.ydb.lock.provider.YdbLockProviderConfiguration -------------------------------------------------------------------------------- /shedlock-ydb/src/test/java/tech/ydb/lock/provider/TestApp.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.lock.provider; 2 | 3 | import org.springframework.boot.autoconfigure.SpringBootApplication; 4 | 5 | /** 6 | * @author Kirill Kurdyukov 7 | */ 8 | @SpringBootApplication 9 | public class TestApp { 10 | } 11 | -------------------------------------------------------------------------------- /shedlock-ydb/src/test/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.datasource.driver-class-name=tech.ydb.jdbc.YdbDriver 2 | 3 | logging.level.tech.ydb.lock.provider=debug -------------------------------------------------------------------------------- /spring-data-jdbc-ydb/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 1.1.0 ## 2 | - Fixed bug: No MethodInvocation found for Spring version 3.4.0 3 | - Added JdbcRepositoryBeanPostProcessor for @ViewIndex annotation 4 | 5 | ## 1.0.0 ## 6 | 7 | - quoting index name in VIEW statement (ex. VIEW \`index_name\`) 8 | 9 | ## 0.9.1 ## 10 | 11 | - Supported VIEW statement from @ViewIndex 12 | - YdbDialect fully supports YQL 13 | - Supported specific @YdbType -------------------------------------------------------------------------------- /spring-data-jdbc-ydb/src/main/java/tech/ydb/data/core/convert/YdbConst.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.data.core.convert; 2 | 3 | /** 4 | * That class contain custom YDB type codes 5 | * @see JDBC Driver constants 6 | * @see Primitive types 7 | * @see Decimal type 8 | * 9 | * @author Aleksandr Gorshenin 10 | */ 11 | final class YdbConst { 12 | public static final int SQL_KIND_PRIMITIVE = 10000; 13 | public static final int SQL_DEFAULT_DECIMAL = ydbDecimal(22, 9); 14 | private static final int SQL_KIND_DECIMAL = 1 << 14; // 16384 15 | 16 | public static int ydbDecimal(int precision, int scale) { 17 | return SQL_KIND_DECIMAL + (precision << 6) + (scale & 0x111111); 18 | } 19 | 20 | private YdbConst() { }; 21 | } 22 | -------------------------------------------------------------------------------- /spring-data-jdbc-ydb/src/main/java/tech/ydb/data/core/convert/YdbSqlType.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.data.core.convert; 2 | 3 | import java.io.Serializable; 4 | import java.sql.SQLType; 5 | 6 | /** 7 | * 8 | * @author Aleksandr Gorshenin 9 | */ 10 | class YdbSqlType implements SQLType, Serializable { 11 | private static final long serialVersionUID = -5722445668088782880L; 12 | 13 | private final String name; 14 | private final int vendorCode; 15 | 16 | public YdbSqlType(YQLType type) { 17 | this.name = type.name(); 18 | this.vendorCode = type.getSqlType(); 19 | } 20 | 21 | public YdbSqlType(int decimalPrecision, int decimalScale) { 22 | this.name = "Decimal(" + decimalPrecision + "," + decimalScale + ")"; 23 | this.vendorCode = YdbConst.ydbDecimal(decimalPrecision, decimalScale); 24 | } 25 | 26 | @Override 27 | public String getName() { 28 | return name; 29 | } 30 | 31 | @Override 32 | public String getVendor() { 33 | return "YDB"; 34 | } 35 | 36 | @Override 37 | public Integer getVendorTypeNumber() { 38 | return vendorCode; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /spring-data-jdbc-ydb/src/main/java/tech/ydb/data/core/convert/YdbType.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.data.core.convert; 2 | 3 | import java.lang.annotation.Documented; 4 | import java.lang.annotation.ElementType; 5 | import java.lang.annotation.Retention; 6 | import java.lang.annotation.RetentionPolicy; 7 | import java.lang.annotation.Target; 8 | 9 | /** 10 | * The annotation for qualification of the target YDB data type. 11 | * 12 | * @author Madiyar Nurgazin 13 | * @author Mikhail Polivakha 14 | * @deprecated Please, use {@link tech.ydb.data.core.convert.annotation.YdbType} instead because of type safety considerations. 15 | */ 16 | @Retention(RetentionPolicy.RUNTIME) 17 | @Target(ElementType.FIELD) 18 | @Deprecated(forRemoval = true) 19 | @Documented 20 | public @interface YdbType { 21 | /** 22 | * The target YDB data type. 23 | * @return name of YDB data type 24 | */ 25 | String value(); 26 | } 27 | -------------------------------------------------------------------------------- /spring-data-jdbc-ydb/src/main/java/tech/ydb/data/core/convert/annotation/YdbType.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.data.core.convert.annotation; 2 | 3 | import java.lang.annotation.Documented; 4 | import java.lang.annotation.ElementType; 5 | import java.lang.annotation.Retention; 6 | import java.lang.annotation.RetentionPolicy; 7 | import java.lang.annotation.Target; 8 | 9 | import tech.ydb.data.core.convert.YQLType; 10 | 11 | 12 | /** 13 | * The annotation for qualification of the target YDB data type. 14 | * 15 | * @author Mikhail Polivakha 16 | * @author Aleksandr Gorshenin 17 | */ 18 | @Retention(RetentionPolicy.RUNTIME) 19 | @Target(ElementType.FIELD) 20 | @Documented 21 | public @interface YdbType { 22 | /** 23 | * The target YDB data type. 24 | * @return The target YDB data type. 25 | */ 26 | YQLType value(); 27 | 28 | /** 29 | * Decimal precision. Applies only to {@link YQLType#Decimal } 30 | * @return Custom decimal type precision. 31 | */ 32 | int decimalPrecision() default 22; 33 | 34 | /** 35 | * Decimal scale. Applies only to {@link YQLType#Decimal } 36 | * @return Custom decimal type scale. 37 | */ 38 | int decimalScale() default 9; 39 | } 40 | -------------------------------------------------------------------------------- /spring-data-jdbc-ydb/src/main/java/tech/ydb/data/core/convert/package-info.java: -------------------------------------------------------------------------------- 1 | @NonNullApi 2 | package tech.ydb.data.core.convert; 3 | 4 | import org.springframework.lang.NonNullApi; -------------------------------------------------------------------------------- /spring-data-jdbc-ydb/src/main/java/tech/ydb/data/core/dialect/package-info.java: -------------------------------------------------------------------------------- 1 | @NonNullApi 2 | package tech.ydb.data.core.dialect; 3 | 4 | import org.springframework.lang.NonNullApi; -------------------------------------------------------------------------------- /spring-data-jdbc-ydb/src/main/java/tech/ydb/data/repository/ViewIndex.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.data.repository; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | /** 9 | * @author Kirill Kurdyukov 10 | */ 11 | @Retention(RetentionPolicy.RUNTIME) 12 | @Target(ElementType.METHOD) 13 | public @interface ViewIndex { 14 | 15 | String indexName() default ""; 16 | 17 | String tableName() default ""; 18 | } 19 | -------------------------------------------------------------------------------- /spring-data-jdbc-ydb/src/main/java/tech/ydb/data/repository/config/package-info.java: -------------------------------------------------------------------------------- 1 | @NonNullApi 2 | package tech.ydb.data.repository.config; 3 | 4 | import org.springframework.lang.NonNullApi; -------------------------------------------------------------------------------- /spring-data-jdbc-ydb/src/main/java/tech/ydb/data/repository/package-info.java: -------------------------------------------------------------------------------- 1 | @NonNullApi 2 | package tech.ydb.data.repository; 3 | 4 | import org.springframework.lang.NonNullApi; -------------------------------------------------------------------------------- /spring-data-jdbc-ydb/src/main/resources/META-INF/spring.factories: -------------------------------------------------------------------------------- 1 | org.springframework.data.jdbc.repository.config.DialectResolver$JdbcDialectProvider=tech.ydb.data.repository.config.YdbDialectProvider 2 | -------------------------------------------------------------------------------- /spring-data-jdbc-ydb/src/test/java/tech/ydb/data/YdbJdbcConfiguration.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.data; 2 | 3 | import org.springframework.context.annotation.Configuration; 4 | import org.springframework.context.annotation.Import; 5 | import org.springframework.data.jdbc.repository.config.EnableJdbcAuditing; 6 | import org.springframework.data.jdbc.repository.config.EnableJdbcRepositories; 7 | import tech.ydb.data.repository.config.AbstractYdbJdbcConfiguration; 8 | 9 | /** 10 | * @author Madiyar Nurgazin 11 | * @author Mikhail Polivakha 12 | */ 13 | @Configuration 14 | @EnableJdbcRepositories( 15 | considerNestedRepositories = true, 16 | basePackages = "tech.ydb.data" 17 | ) 18 | @EnableJdbcAuditing 19 | @Import(AbstractYdbJdbcConfiguration.class) 20 | public class YdbJdbcConfiguration {} -------------------------------------------------------------------------------- /spring-data-jdbc-ydb/src/test/java/tech/ydb/data/all_types_table/repository/AllTypesEntityRepository.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.data.all_types_table.repository; 2 | 3 | import java.util.List; 4 | import org.springframework.data.jdbc.repository.query.Query; 5 | import org.springframework.data.repository.ListCrudRepository; 6 | import org.springframework.data.repository.query.Param; 7 | import tech.ydb.data.all_types_table.entity.AllTypesEntity; 8 | import tech.ydb.data.repository.ViewIndex; 9 | 10 | /** 11 | * @author Madiyar Nurgazin 12 | */ 13 | public interface AllTypesEntityRepository extends ListCrudRepository { 14 | @Query("select count(distinct text_column) from all_types_table") 15 | long countDistinctTextColumn(); 16 | 17 | @Query("select * from all_types_table where date_column > CurrentUtcDate()") 18 | List findAllByDateColumnAfterNow(); 19 | 20 | @ViewIndex(indexName = "text_column_index") 21 | List findAllByTextColumn(@Param("textColumn") String textColumn); 22 | } 23 | -------------------------------------------------------------------------------- /spring-data-jdbc-ydb/src/test/java/tech/ydb/data/books/entity/BookAuthor.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.data.books.entity; 2 | 3 | import org.springframework.data.relational.core.mapping.Table; 4 | 5 | /** 6 | * @author Madiyar Nurgazin 7 | */ 8 | @Table("books_authors") 9 | public record BookAuthor(long authorId, long bookId) { 10 | } 11 | -------------------------------------------------------------------------------- /spring-data-jdbc-ydb/src/test/java/tech/ydb/data/books/repository/AuthorRepository.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.data.books.repository; 2 | 3 | import java.util.List; 4 | import org.springframework.data.jdbc.repository.query.Query; 5 | import org.springframework.data.repository.ListCrudRepository; 6 | import org.springframework.data.repository.query.Param; 7 | import tech.ydb.data.books.entity.Author; 8 | import tech.ydb.data.repository.ViewIndex; 9 | 10 | /** 11 | * @author Madiyar Nurgazin 12 | */ 13 | public interface AuthorRepository extends ListCrudRepository { 14 | @Query("select authors.* from authors join books_authors on authors.id = books_authors.author_id" + 15 | " where books_authors.book_id = :bookId") 16 | List findAuthorsByBookId(@Param("bookId") long bookId); 17 | 18 | @ViewIndex(indexName = "name_authors_index", tableName = "authors") 19 | List findAuthorByName(@Param("name") String name); 20 | } 21 | -------------------------------------------------------------------------------- /spring-data-jdbc-ydb/src/test/java/tech/ydb/data/books/repository/BookRepository.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.data.books.repository; 2 | 3 | import java.util.List; 4 | import java.util.Optional; 5 | import org.springframework.data.jdbc.repository.query.Query; 6 | import org.springframework.data.repository.CrudRepository; 7 | import org.springframework.data.repository.query.Param; 8 | import tech.ydb.data.books.entity.Book; 9 | import tech.ydb.data.repository.ViewIndex; 10 | 11 | /** 12 | * @author Madiyar Nurgazin 13 | */ 14 | public interface BookRepository extends CrudRepository { 15 | @Query("select books.* from books join books_authors on books.id = books_authors.book_id" + 16 | " join authors on authors.id = books_authors.author_id where name = :author") 17 | List findBooksByAuthorName(@Param("author") String author); 18 | 19 | @ViewIndex(indexName = "isbn_books_index", tableName = "books") 20 | List findBookByIsbn(String isbn); 21 | 22 | Optional findBookByTitle(String title); 23 | } 24 | -------------------------------------------------------------------------------- /spring-data-jdbc-ydb/src/test/java/tech/ydb/data/books/repository/ReviewRepository.java: -------------------------------------------------------------------------------- 1 | package tech.ydb.data.books.repository; 2 | 3 | import java.util.List; 4 | import org.springframework.data.domain.Pageable; 5 | import org.springframework.data.repository.CrudRepository; 6 | import org.springframework.data.repository.ListCrudRepository; 7 | import org.springframework.data.repository.PagingAndSortingRepository; 8 | import tech.ydb.data.books.entity.Review; 9 | 10 | /** 11 | * @author Madiyar Nurgazin 12 | */ 13 | public interface ReviewRepository extends ListCrudRepository, 14 | CrudRepository, PagingAndSortingRepository { 15 | 16 | List findByReader(String reader, Pageable pageable); 17 | } 18 | -------------------------------------------------------------------------------- /spring-data-jdbc-ydb/src/test/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.datasource.driver-class-name=tech.ydb.jdbc.YdbDriver 2 | spring.datasource.url=jdbc:ydb:grpc://localhost:2136/local 3 | 4 | spring.liquibase.change-log=classpath:changelogs/changelog.yaml 5 | 6 | logging.level.org.springframework.jdbc.core.JdbcTemplate=debug 7 | logging.level.liquibase=DEBUG 8 | -------------------------------------------------------------------------------- /spring-data-jdbc-ydb/src/test/resources/changelogs/changelog.yaml: -------------------------------------------------------------------------------- 1 | databaseChangeLog: 2 | - include: 3 | file: "all_types_table.yaml" 4 | relativeToChangelogFile: true 5 | - include: 6 | file: "books.yaml" 7 | relativeToChangelogFile: true 8 | - changeSet: 9 | id: "insert-all-types-table" 10 | author: "Madiyar Nurgazin" 11 | context: all 12 | changes: 13 | - loadData: 14 | tableName: "all_types_table" 15 | file: "insert_all_types_table.csv" 16 | relativeToChangelogFile: true 17 | -------------------------------------------------------------------------------- /spring-data-jdbc-ydb/src/test/resources/changelogs/insert.sql: -------------------------------------------------------------------------------- 1 | INSERT INTO reviews (id, text, rating, created, book_id, reader) 2 | VALUES (1, 'Masterpiece!', 10, TIMESTAMP('2024-03-19T15:52:26Z'), 1, 'Ivan Ivanov'), 3 | (2, 'Complex work, but I liked it', 9, TIMESTAMP('2024-03-19T16:14:05Z'), 1, 'Sergey Petrov') -------------------------------------------------------------------------------- /spring-data-jdbc-ydb/src/test/resources/changelogs/insert_all_types_table.csv: -------------------------------------------------------------------------------- 1 | id,text_column,bool_column,tinyint_column,smallint_column,bigint_column,float_column,double_column,decimal_column,binary_column,date_column,datetime_column,timestamp_column,json_column,json_document_column,uint8_column,uint16_column,uint32_column,uint64_column 2 | 1,Madiyar Nurgazin,true,1,2,123123,1.123,1.123123,1.123123,binary,2024-03-19,2024-03-20T10:30,2024-07-21T17:00:00.000000Z,{"a" : "b"},{"c" : "d"},3,4,5,12341234 3 | 2,Madiyar Nurgazin,true,1,2,123123,1.123,1.123123,1.123123,binary,2024-03-19,2024-03-20T10:30,2024-02-21T17:00:00.000000Z,{"a" : "b"},{"c" : "d"},3,4,5,12341234 4 | 3,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null 5 | --------------------------------------------------------------------------------