All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.ebeaninternal.dbmigration.ddlgeneration.platform.ClickHouseDbArray Maven / Gradle / Ivy

There is a newer version: 12.5.2
Show newest version
package io.ebeaninternal.dbmigration.ddlgeneration.platform;

import java.util.HashMap;
import java.util.Map;

/**
 * Logical array type to ClickHouse array type conversion.
 */
class ClickHouseDbArray {

  private static final Map mapping = new HashMap<>();
  static {
    mapping.put("uuid[]", "Array(UUID)");
    mapping.put("varchar[]", "Array(String)");
    mapping.put("integer[]", "Array(UInt32)");
    mapping.put("bigint[]", "Array(UInt64)");
  }

  /**
   * Covert the 'logical' array type to a native one (for Postgres and Cockroach).
   */
  static String logicalToNative(String logicalArrayType) {
    int colonPos = logicalArrayType.indexOf(':');
    if (colonPos > -1) {
      logicalArrayType = logicalArrayType.substring(0, colonPos);
    }
    String clickHouseType = mapping.get(logicalArrayType);
    if (clickHouseType == null) {
      throw new IllegalStateException("No mapping for logical array type " + logicalArrayType);
    }
    return clickHouseType;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy