Exemplo n.º 1
0
        public static string ToString(string columnName, ClickHouseValueType valueType, bool isNullable = false, bool isLowCardinality = false
                                      , bool isArray = false, int?fixedStringLength = null, string defaultExpression = null)
        {
            string typeName;

            if (valueType == ClickHouseValueType.String)
            {
                typeName = isLowCardinality
                    ? $"LowCardinality({valueType})"
                    : valueType.ToString();
            }
            else if (valueType == ClickHouseValueType.FixedString)
            {
                if (fixedStringLength == null)
                {
                    throw new ArgumentNullException(nameof(fixedStringLength));
                }
                typeName = $"{valueType}({fixedStringLength})";
            }
            else
            {
                typeName = valueType.ToString();
            }

            if (isNullable)
            {
                typeName = $"Nullable({typeName})";
            }
            if (isArray)
            {
                typeName = $"Array({typeName})";
            }
            return($"{columnName} {typeName}"
                   + (!string.IsNullOrWhiteSpace(defaultExpression) ? $" DEFAULT {defaultExpression}" : ""));
        }
Exemplo n.º 2
0
 public ClickHouseColumn(string name, ClickHouseValueType valueType, bool isNullable = false, bool isArray = false, int?fixedStringLength = null, ColumnMappingSide mappingSide = ColumnMappingSide.Both)
 {
     Name              = name;
     ValueType         = valueType;
     IsNullable        = isNullable;
     IsArray           = isArray;
     FixedStringLength = fixedStringLength;
     MappingSide       = mappingSide;
 }
Exemplo n.º 3
0
 public static string dictGetOrDefault(string dictName, string attrName, string id, object defaultValue, ClickHouseValueType valueType) =>
 $"dictGet{valueType}OrDefault('{dictName}','{attrName}',{id},{defaultValue.AsClickValue()})";
Exemplo n.º 4
0
 public static string dictGet(string dictName, string attrName, string idExpr, ClickHouseValueType valueType) => $"dictGet{valueType}('{dictName}','{attrName}',{idExpr})";