Luis Munoz

    Luis Munoz

    2 years ago
    I'm thinking about using exposed with MemSQL which supports mariadb driver. I cannot figure out how to create a table because it needs these SHARD statement, how do I add that?
    sqlQueryBuilder.append("id BIGINT AUTO_INCREMENT NOT NULL,");
    sqlQueryBuilder.append("ts DATETIME(6) NOT NULL,");
    sqlQueryBuilder.append("uuid VARBINARY(32) NOT NULL,");
    sqlQueryBuilder.append("data JSON,");
    sqlQueryBuilder.append("SHARD(id),");
    sqlQueryBuilder.append("KEY(ts) USING CLUSTERED COLUMNSTORE)");
    is it possible to get the same statement with exposed?
    tapac

    tapac

    2 years ago
    It's unsupported yet, but you could "hack" deafult create by implementing your own table type. Something like:
    abstract class ShardedTable(tableName: String, val shard: String) : Table(tableName) {
    
        override fun createStatement(): List<String> {
            return super.createStatement().map { statement ->
                if (statement.startsWith("CREATE TABLE "))
                    statement.removeSuffix(")") + "SHARD($shard))"
                else statement
            }
        }
    }
    It's the example, tune it with the right syntax.
    Luis Munoz

    Luis Munoz

    2 years ago
    thank you