Skip to content

Commit

Permalink
[core] all catalogs use 'allow-upper-case' to control case-sensitive (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
LsomeYeah authored Nov 20, 2024
1 parent da4d64b commit 6e8c03d
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public final class FileSystemCatalogOptions {
ConfigOptions.key("case-sensitive")
.booleanType()
.defaultValue(true)
.withFallbackKeys("allow-upper-case")
.withDescription(
"Is case sensitive. If case insensitive, you need to set this option to false, and the table name and fields be converted to lowercase.");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,52 @@
package org.apache.paimon.catalog;

import org.apache.paimon.fs.Path;
import org.apache.paimon.options.CatalogOptions;
import org.apache.paimon.options.Options;
import org.apache.paimon.schema.Schema;
import org.apache.paimon.types.DataTypes;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import static org.assertj.core.api.Assertions.assertThatExceptionOfType;

/** Tests for {@link FileSystemCatalog}. */
public class FileSystemCatalogTest extends CatalogTestBase {

@BeforeEach
public void setUp() throws Exception {
super.setUp();
catalog = new FileSystemCatalog(fileIO, new Path(warehouse));
Options catalogOptions = new Options();
catalogOptions.set(CatalogOptions.ALLOW_UPPER_CASE, false);
catalog = new FileSystemCatalog(fileIO, new Path(warehouse), catalogOptions);
}

@Test
public void testCreateTableAllowUpperCase() throws Exception {
catalog.createDatabase("test_db", false);
Identifier identifier = Identifier.create("test_db", "new_table");
Schema schema =
Schema.newBuilder()
.column("Pk1", DataTypes.INT())
.column("pk2", DataTypes.STRING())
.column("pk3", DataTypes.STRING())
.column(
"Col1",
DataTypes.ROW(
DataTypes.STRING(),
DataTypes.BIGINT(),
DataTypes.TIMESTAMP(),
DataTypes.ARRAY(DataTypes.STRING())))
.column("col2", DataTypes.MAP(DataTypes.STRING(), DataTypes.BIGINT()))
.column("col3", DataTypes.ARRAY(DataTypes.ROW(DataTypes.STRING())))
.partitionKeys("Pk1", "pk2")
.primaryKey("Pk1", "pk2", "pk3")
.build();

// Create table throws Exception when table is system table
assertThatExceptionOfType(IllegalArgumentException.class)
.isThrownBy(() -> catalog.createTable(identifier, schema, false))
.withMessage("Field name [Pk1, Col1] cannot contain upper case in the catalog.");
}
}

0 comments on commit 6e8c03d

Please sign in to comment.