Class ClickHouseDialect
- Namespace
- NextORM.ClickHouse
- Assembly
- nextorm.clickhouse.dll
ClickHouse dialect: backtick-quoted identifiers, @name parameters, concat(...)
concatenation, limit/offset paging, ClickHouse type names and the camel-case
standard-deviation/variance aggregate names. ClickHouse has no recursive CTE support, so the
recursive modifier is omitted.
public class ClickHouseDialect : SqlDialectBase, ISqlDialect
- Inheritance
-
ClickHouseDialect
- Implements
- Inherited Members
- Extension Methods
Remarks
The type is deliberately not sealed. Subclassing it and overriding
ExtremeRowRenderer is the supported external extension boundary (a public
compatibility commitment), so an assembly without InternalsVisibleTo can install its own
public IExtremeRowRenderer. The built-in renderer is internal and is not part
of that contract. The public constructor and the shared Instance are preserved;
returning null from an override keeps the portable window-function lowering.
Constructors
ClickHouseDialect()
Creates the dialect and its capability renderers. The constructor is public so an external assembly can derive a custom dialect from ClickHouseDialect.
public ClickHouseDialect()
ClickHouseDialect(Version)
Creates a dialect bound to an explicitly declared ClickHouse server version. The declaration is
caller-supplied (there is no server probing): it only widens the capability set for the gates
whose native function appeared in a later ClickHouse release (currently arrayExcept from
25.9). An undeclared dialect keeps the pinned-baseline surface, i.e. the shared
Instance renderers.
public ClickHouseDialect(Version serverVersion)
Parameters
serverVersionVersionThe ClickHouse server version this dialect declares.
Exceptions
- ArgumentNullException
serverVersionis null; use the parameterless constructor for an undeclared dialect.
Fields
Instance
The shared ClickHouse dialect instance. Subclassing the dialect does not change this instance; a derived dialect is created through the public constructor instead.
public static readonly ClickHouseDialect Instance
Field Value
Properties
AggregateFilterStyle
ClickHouse renders an aggregate filter as the -If combinator (sumIf, countIf).
public override AggregateFilterStyle AggregateFilterStyle { get; }
Property Value
ArrayJoinClause
ClickHouse implements the ARRAY JOIN clause.
public override IArrayJoinRenderer ArrayJoinClause { get; }
Property Value
ClickHouseAggregates
ClickHouse implements the ClickHouse-only aggregate catalogue (statistical, quantile-algorithm, array/tuple and time-series aggregates).
public override IClickHouseAggregateRenderer ClickHouseAggregates { get; }
Property Value
DateConversion
ClickHouse exposes the native date conversion/truncation surface (toDate/toDateTime/
toDate32, the toYear/... part accessors, toStartOf*, toMonday,
toYYYYMM/toYYYYMMDD, toUnixTimestamp).
public override IDateConversionRenderer DateConversion { get; }
Property Value
DeleteRequiresWhere
ClickHouse's ALTER TABLE ... DELETE mutation requires a WHERE clause.
public override bool DeleteRequiresWhere { get; }
Property Value
ExtremeRowRenderer
ClickHouse renders eligible SelectWhereMax/SelectWhereMin with argMin/argMax over a payload tuple; the rest falls back to the portable window function.
The property is virtual so a derived dialect can override it with a custom
IExtremeRowRenderer; returning null keeps the portable
window-function lowering. The built-in renderer is internal and is not a public contract.
public override IExtremeRowRenderer? ExtremeRowRenderer { get; }
Property Value
Iif
ClickHouse renders the portable iif as if(condition, whenTrue, whenFalse).
public override IIifRenderer Iif { get; }
Property Value
LimitBy
ClickHouse implements LIMIT n BY expr.
public override ILimitByRenderer LimitBy { get; }
Property Value
MultiIf
ClickHouse implements the multi-branch conditional multiIf(cond1, then1, ..., else).
public override IMultiIfRenderer MultiIf { get; }
Property Value
NativeJsonProviderType
ClickHouse materializes and binds its native JSON type as a
JsonObject (the driver's object-root DOM).
public override Type NativeJsonProviderType { get; }
Property Value
NullSafeComparison
ClickHouse emulates both null-safe comparison forms over guarded ordinary equality: its native
isNotDistinctFrom/<=> spellings are restricted to the JOIN ON section (Code 48
outside it), so they are never emitted in a predicate or scalar position.
public override INullSafeComparisonRenderer? NullSafeComparison { get; }
Property Value
OuterJoinNullSettings
ClickHouse fills the unmatched side of an outer join with column defaults unless
join_use_nulls=1 is set; reference-navigation materialization needs real SQL nulls to see an
absent principal, so the core preparation injects it query-locally.
public override IReadOnlyList<KeyValuePair<string, string>> OuterJoinNullSettings { get; }
Property Value
QuantileAggregates
ClickHouse implements the parameterised quantile(level)(value) family and median.
public override IQuantileAggregateRenderer QuantileAggregates { get; }
Property Value
RequireSubqueryAlias
A ClickHouse derived table (subquery in FROM) must have an alias.
public override bool RequireSubqueryAlias { get; }
Property Value
ScalarFunctions
ClickHouse renders every cross-provider scalar function (UTF-8 character-wise where it matters).
public override IScalarFunctions ScalarFunctions { get; }
Property Value
SequenceAggregates
ClickHouse implements the windowFunnel/retention/sequenceMatch aggregates.
public override ISequenceAggregateRenderer SequenceAggregates { get; }
Property Value
SessionInfoFunctions
ClickHouse renders currentUser(), currentDatabase() and version(); it has no
session-user or schema concept, so session_user/current_schema stay unavailable.
public override ISessionInfoFunctions SessionInfoFunctions { get; }
Property Value
StringFormats
ClickHouse renders CLR format specifiers through format/formatDateTime.
public override IStringFormatFunctions? StringFormats { get; }
Property Value
StringSplit
ClickHouse renders string.Split as splitByChar(separator, value).
public override IStringSplitRenderer StringSplit { get; }
Property Value
SupportsAnyLastAggregate
ClickHouse implements the any/anyLast row-picking aggregates.
public override bool SupportsAnyLastAggregate { get; }
Property Value
SupportsAnyValueAggregate
ClickHouse renders the arbitrary-value aggregate as any(x).
public override bool SupportsAnyValueAggregate { get; }
Property Value
SupportsArgMinMax
ClickHouse implements the argMin/argMax aggregates.
public override bool SupportsArgMinMax { get; }
Property Value
SupportsArrayFunctions
ClickHouse has a native Array(T) type and implements the array functions over array
columns (length, has, indexOf, arrayStringConcat, hasAny/hasAll,
startsWith/endsWith/hasSubstr, arraySort, arrayReverse, arrayDistinct,
splitByChar).
public override bool SupportsArrayFunctions { get; }
Property Value
SupportsArrayJoin
ClickHouse implements arrayJoin(array), which expands one row per element.
public override bool SupportsArrayJoin { get; }
Property Value
SupportsBitAggregates
ClickHouse implements the bit aggregates as groupBitAnd/groupBitOr/groupBitXor.
public override bool SupportsBitAggregates { get; }
Property Value
SupportsBulkCopy
ClickHouse has a native bulk path: the driver's ClickHouseClient.InsertBinaryAsync streams
RowBinary rows over HTTP, so the native path is selected where a ClickHouse client is available and
the portable INSERT ... VALUES path stays the compatible fallback. The legacy
ClickHouseBulkCopy wrapper is not used.
public override bool SupportsBulkCopy { get; }
Property Value
SupportsCollation
ClickHouse has no COLLATE clause.
public override bool SupportsCollation { get; }
Property Value
SupportsCommandBehaviorSingleRow
ClickHouse is false because the driver would append a duplicate LIMIT 1 to the one the dialect already renders.
public override bool SupportsCommandBehaviorSingleRow { get; }
Property Value
SupportsCreateTableAsSelect
ClickHouse materialises a query into a persistent table with CREATE TABLE ... ENGINE = ... AS SELECT.
public override bool SupportsCreateTableAsSelect { get; }
Property Value
SupportsCreateTableAsSelectIfNotExists
ClickHouse accepts IF NOT EXISTS on CREATE TABLE ... AS SELECT.
public override bool SupportsCreateTableAsSelectIfNotExists { get; }
Property Value
SupportsCrossDatabase
ClickHouse qualifies a table with a database name (); there is no separate schema level.db.table
public override bool SupportsCrossDatabase { get; }
Property Value
SupportsCube
ClickHouse spells CUBE as the trailing modifier GROUP BY ... WITH CUBE.
public override bool SupportsCube { get; }
Property Value
SupportsDateArithmetic
ClickHouse implements date arithmetic through its addYears/.../addSeconds family.
public override bool SupportsDateArithmetic { get; }
Property Value
SupportsDateTimeOffsetTranslation
ClickHouse stores a DateTimeOffset as a UTC-normalized DateTime64, so DTO operations are supported.
public override bool SupportsDateTimeOffsetTranslation { get; }
Property Value
SupportsDateTrunc
ClickHouse implements date truncation through dateTrunc(unit, value).
public override bool SupportsDateTrunc { get; }
Property Value
SupportsDictionaries
ClickHouse implements the dictionary functions dictGet/dictGetOrDefault/
dictGetOrNull/dictGetAll/dictGetDescendants/dictHas/
dictGetHierarchy/dictGetChildren/dictIsIn and the embedded-geobase region
functions regionToName/regionToCity/regionToArea/regionToDistrict/
regionToCountry/regionToContinent/regionToTopContinent/
regionToPopulation/regionHierarchy/regionIn.
public override bool SupportsDictionaries { get; }
Property Value
SupportsFinal
ClickHouse implements the FINAL table modifier.
public override bool SupportsFinal { get; }
Property Value
SupportsGlobalJoin
ClickHouse implements the GLOBAL join modifier.
public override bool SupportsGlobalJoin { get; }
Property Value
SupportsGlobalPredicates
ClickHouse implements the distributed GLOBAL IN predicate.
public override bool SupportsGlobalPredicates { get; }
Property Value
SupportsGreatestLeast
ClickHouse renders the standard greatest(...)/least(...) functions.
public override bool SupportsGreatestLeast { get; }
Property Value
SupportsGroupByWithTotals
ClickHouse implements the GROUP BY ... WITH TOTALS modifier.
public override bool SupportsGroupByWithTotals { get; }
Property Value
SupportsGroupingSets
ClickHouse supports GROUP BY GROUPING SETS (...).
public override bool SupportsGroupingSets { get; }
Property Value
SupportsHigherOrderArrayFunctions
ClickHouse implements the higher-order (lambda) array functions (arrayMap,
arrayFilter, arrayExists, arrayAll, arrayCount,
arrayFirst*, arrayLast*).
public override bool SupportsHigherOrderArrayFunctions { get; }
Property Value
SupportsInFrameWindowFunctions
ClickHouse implements the frame-respecting offset window functions lagInFrame/leadInFrame
(unlike the standard lag/lead, which ignore the window frame).
public override bool SupportsInFrameWindowFunctions { get; }
Property Value
SupportsInsertIgnore
ClickHouse has no unique constraint and no INSERT IGNORE form, so a duplicate-skipping
request cannot be expressed. Capability is reported as false so the request is
refused by name instead of being silently rendered as a plain INSERT INTO that writes every
row.
public override bool SupportsInsertIgnore { get; }
Property Value
SupportsIntersectExceptAll
ClickHouse implements the INTERSECT ALL/EXCEPT ALL set-operation variants.
public override bool SupportsIntersectExceptAll { get; }
Property Value
SupportsJoinStrictness
ClickHouse implements the ANY/ALL/ASOF join modifiers.
public override bool SupportsJoinStrictness { get; }
Property Value
SupportsJson
ClickHouse has a native JSON type and stores a mapped JSON column as it. This is the
storage capability only: the PostgreSQL JSON functions/operators surface stays opt-out, because
ClickHouse has no json_agg/->/@> and its own JSON surface is
SupportsJsonExtract.
public override bool SupportsJson { get; }
Property Value
SupportsJsonExtract
ClickHouse implements the JSONExtract*/JSONHas/visitParamExtract* string-JSON
family and the JSONPath scalars JSON_VALUE/JSON_QUERY/JSON_EXISTS.
public override bool SupportsJsonExtract { get; }
Property Value
SupportsNamedWindows
ClickHouse declares named windows (WINDOW w AS (...)) and references them with OVER w.
public override bool SupportsNamedWindows { get; }
Property Value
SupportsNthValue
ClickHouse implements the nth_value(value, n) window function.
public override bool SupportsNthValue { get; }
Property Value
SupportsNullsOrdering
ClickHouse renders the native NULLS FIRST/NULLS LAST ordering modifier.
public override bool SupportsNullsOrdering { get; }
Property Value
SupportsOrdinalComparison
ClickHouse's native String order is byte-order, so ordinal comparison is native.
public override bool SupportsOrdinalComparison { get; }
Property Value
SupportsPasteJoin
ClickHouse implements the PASTE join kind.
public override bool SupportsPasteJoin { get; }
Property Value
SupportsPercentRankCumeDist
ClickHouse implements the percent_rank/cume_dist window functions.
public override bool SupportsPercentRankCumeDist { get; }
Property Value
SupportsPreWhere
ClickHouse implements the PREWHERE clause.
public override bool SupportsPreWhere { get; }
Property Value
SupportsRangeColumns
True when the provider can store a Range<T> as a pair of scalar columns declared with RangeColumnsAttribute; false by default. See SupportsRangeColumns.
public override bool SupportsRangeColumns { get; }
Property Value
SupportsRawSqlSource
ClickHouse supports a raw SQL derived table (FROM (<sql>) AS alias).
public override bool SupportsRawSqlSource { get; }
Property Value
SupportsRecursiveCte
ClickHouse has no recursive WITH, so the new typed recursive CTE API fails closed.
public override bool SupportsRecursiveCte { get; }
Property Value
SupportsReferenceToCollectionNavigation
ClickHouse cannot correlate a subquery on a joined source alias (the engine reports
NOT_IMPLEMENTED: can't find correlated column), so a collection reached through a
reference navigation is rejected by navigation expansion.
public override bool SupportsReferenceToCollectionNavigation { get; }
Property Value
SupportsRegex
ClickHouse matches with the RE2-based match and replaces with replaceRegexpAll.
public override bool SupportsRegex { get; }
Property Value
SupportsRollup
ClickHouse spells ROLLUP as the trailing modifier GROUP BY ... WITH ROLLUP.
public override bool SupportsRollup { get; }
Property Value
SupportsSample
ClickHouse implements the SAMPLE table modifier.
public override bool SupportsSample { get; }
Property Value
SupportsSelectWhereMinMax
ClickHouse 21+ renders SelectWhereMax/SelectWhereMin with a window function.
public override bool SupportsSelectWhereMinMax { get; }
Property Value
SupportsSemiAntiJoin
ClickHouse implements the LEFT SEMI/LEFT ANTI join kinds.
public override bool SupportsSemiAntiJoin { get; }
Property Value
SupportsSettings
ClickHouse implements the trailing SETTINGS clause.
public override bool SupportsSettings { get; }
Property Value
SupportsStatisticalAggregates
ClickHouse implements the statistical aggregates as corr/covarPop/covarSamp.
public override bool SupportsStatisticalAggregates { get; }
Property Value
SupportsStringAgg
ClickHouse renders string_agg through arrayStringConcat(groupArray(value), delimiter); array_agg stays unavailable.
public override bool SupportsStringAgg { get; }
Property Value
SupportsTableValuedParameters
ClickHouse emulates a table-valued parameter with a native array bound through the driver and
expanded server-side with arrayJoin(@p): a scalar set is an Array(T) and an entity
set an Array(Tuple(...)). See ClickHouseDataContext.CreateProcedureParameter.
public override bool SupportsTableValuedParameters { get; }
Property Value
SupportsTemporaryCreateTableAsSelect
ClickHouse temporary tables take an explicit column list and no AS SELECT, so only a persistent ToTable is supported.
public override bool SupportsTemporaryCreateTableAsSelect { get; }
Property Value
SupportsTransactions
ClickHouse is false because its HTTP protocol has no ADO.NET transaction.
public override bool SupportsTransactions { get; }
Property Value
SupportsTruncate
ClickHouse has a native synchronous TRUNCATE TABLE.
public override bool SupportsTruncate { get; }
Property Value
SupportsWindowFrameGroups
ClickHouse supports the GROUPS window frame unit.
public override bool SupportsWindowFrameGroups { get; }
Property Value
TopKAggregates
ClickHouse implements the parameterised topK(N)(value)/topKWeighted(N)(value, weight) aggregates.
public override ITopKAggregateRenderer TopKAggregates { get; }
Property Value
Tuple
ClickHouse has a native Tuple(...) type and implements the tuple constructor and
tupleElement access.
public override ITupleRenderer? Tuple { get; }
Property Value
UniqAggregates
ClickHouse implements the distinct-count uniq* aggregates.
public override IUniqAggregateRenderer UniqAggregates { get; }
Property Value
UpdateRequiresWhere
ClickHouse's ALTER TABLE ... UPDATE mutation requires a WHERE clause.
public override bool UpdateRequiresWhere { get; }
Property Value
UuidGenerators
ClickHouse renders both UUID generators.
public override IUuidGenerators UuidGenerators { get; }
Property Value
WrapsAverageResult
ClickHouse avg returns nan for an empty input, so the AVG result is wrapped in an eligibility check.
public override bool WrapsAverageResult { get; }
Property Value
WrapsCountResult
ClickHouse's count/countIf return UInt64, so the result is cast to the declared CLR type.
public override bool WrapsCountResult { get; }
Property Value
Methods
Escape(string)
ClickHouse quotes aliases with backticks (single-quoted aliases are syntax errors), escaping an embedded backslash or backtick. null yields the empty quoted identifier.
public override string Escape(string keyword)
Parameters
keywordstring
Returns
MakeAggregate(string)
Maps the portable aggregate name to its ClickHouse spelling (for example stdev to stddevSamp).
public override string MakeAggregate(string name)
Parameters
namestring
Returns
MakeArrayFunction(string, string)
length, indexOf, arrayCount, arrayFirstIndex and
arrayLastIndex return UInt64/UInt32 natively; cast them to Int64 so
the result matches the declared CLR long.
public override string MakeArrayFunction(string name, string call)
Parameters
Returns
MakeArrayResult(string, string, Type)
Normalises the result of the array-producing facades to the closed declared CLR array type.
ClickHouse infers the element type from the arguments and the server defaults
(retention → Array(UInt8), range(3) → Array(UInt8), an arrayMap
or top_k whose native element type is wider than the declared one → Array(Int64)), so
a targeted result is wrapped in exactly one cast(<call> as Array(...)). Every other
facade result is returned unchanged.
public override string MakeArrayResult(string name, string call, Type resultType)
Parameters
Returns
MakeAverageResult(string, string, string?, string?)
Wraps a rendered AVG expression as if(count(...)=0, cast(null as Nullable(Float64)), agg);
the filtered form checks countIf(isNotNull(x) AND predicate) and the window form uses the
identical over clause for the count.
public override string MakeAverageResult(string aggregate, string argument, string? filterPredicate = null, string? windowClause = null)
Parameters
Returns
MakeBool(bool)
ClickHouse has a native boolean type, rendered as true/false.
public override string MakeBool(bool v)
Parameters
vbool
Returns
MakeCoalesce(string, string)
Renders the standard coalesce(v1, v2).
public override string MakeCoalesce(string v1, string v2)
Parameters
Returns
MakeColumnReference(string)
ClickHouse uses the backtick-quoted identifier for references as well.
public override string MakeColumnReference(string name)
Parameters
namestring
Returns
MakeConcat(IReadOnlyList<string>)
ClickHouse concatenates with the concat(part, ...) function rather than the + operator.
public override string MakeConcat(IReadOnlyList<string> parts)
Parameters
partsIReadOnlyList<string>
Returns
MakeCreateTableAsSelect(CreateTableAsClause, string, KeywordCase)
Renders the ClickHouse CREATE TABLE ... ENGINE = MergeTree ORDER BY tuple() AS SELECT form (an explicit engine is required).
public override string MakeCreateTableAsSelect(CreateTableAsClause clause, string selectSql, KeywordCase keywordCase = KeywordCase.Lower)
Parameters
clauseCreateTableAsClauseselectSqlstringkeywordCaseKeywordCase
Returns
MakeDateAdd(string, string, string)
ClickHouse adds intervals through the dedicated addYears/addQuarters/.../addSeconds
functions. decade/century are folded onto a scaled addYears; the year family
(year/decade/century) promotes its operand to DateTime64(6), because
addYears on a 4-byte DateTime wraps past 2106 while DateTime64 reaches 2299.
millennium is rejected: the pinned 25.8 server cannot represent such results.
public override string MakeDateAdd(string field, string amount, string value)
Parameters
Returns
MakeDateAdd(string, string, string, bool)
DTO date addition runs on an explicit UTC-normalized DateTime64 value. ClickHouse
addXxx truncates a fractional interval to whole units, so a coarse-unit DTO amount is
scaled to addMicroseconds (the finest addXxx matching the documented
DateTime64(6) precision), keeping a significant fraction instead of collapsing it to a
no-op. Integer amounts stay correct through the same scaling.
public override string MakeDateAdd(string field, string amount, string value, bool isDateTimeOffset)
Parameters
Returns
MakeDateDiff(string, string, string)
ClickHouse computes date differences through dateDiff(unit, start, end).
public override string MakeDateDiff(string field, string start, string end)
Parameters
Returns
MakeDateDiffBig(string, string, string)
Renders the native 64-bit dateDiff(unit, start, end): ClickHouse already answers with
Int64, so date_diff_big must not inherit the narrow toInt32 renderer.
public override string MakeDateDiffBig(string field, string start, string end)
Parameters
Returns
MakeDateFromParts(string, string, string)
Renders makeDate(year, month, day).
public override string MakeDateFromParts(string year, string month, string day)
Parameters
Returns
MakeDatePart(string, string)
ClickHouse spells the date parts through the toXxx family; the accessors return
UInt8/UInt16, which the row reader cannot read through GetInt32, so they are cast. The
normalised parts follow the cross-provider extract contract: week is ISO 8601,
dow is 0=Sunday..6=Saturday (native toDayOfWeek is ISO 1..7, hence % 7) and
isodow is 1=Monday..7=Sunday.
public override string MakeDatePart(string part, string value)
Parameters
Returns
MakeDatePart(string, string, bool)
DTO date parts are taken from an explicit UTC-normalized value so the result does not depend on
the column's declared time zone, then rendered through the native toXxx accessors.
public override string MakeDatePart(string part, string value, bool isDateTimeOffset)
Parameters
Returns
MakeDateTimeOffsetNow(bool)
Renders the UTC server clock at microsecond precision. ClickHouse DateTime64 does not
preserve an offset, so a materialized DateTimeOffset canonicalises to +00:00.
public override string MakeDateTimeOffsetNow(bool utc)
Parameters
utcbool
Returns
MakeDateTrunc(string, string)
ClickHouse truncates through dateTrunc(unit, value). It accepts second..year
and the sub-second units for DateTime64, but has no decade/century/millennium;
the plural ANSI sub-second names map to the ClickHouse singular ones.
public override string MakeDateTrunc(string field, string value)
Parameters
Returns
MakeDeleteHead(string, KeywordCase)
ClickHouse deletes through the synchronous ALTER TABLE ... DELETE mutation with SETTINGS mutations_sync = 1.
public override string MakeDeleteHead(string table, KeywordCase keywordCase = KeywordCase.Lower)
Parameters
tablestringkeywordCaseKeywordCase
Returns
MakeDeleteSuffix(KeywordCase)
Waits for the ClickHouse mutation, so a delete is visible to the next statement.
public override string? MakeDeleteSuffix(KeywordCase keywordCase = KeywordCase.Lower)
Parameters
keywordCaseKeywordCase
Returns
MakeDictionaryFunction(string, IReadOnlyList<string>)
ClickHouse spells the dictionary and region functions in camel case.
public override string MakeDictionaryFunction(string name, IReadOnlyList<string> args)
Parameters
namestringargsIReadOnlyList<string>
Returns
MakeDurationType(DurationUnit?, int)
ClickHouse has no native duration type read back as TimeSpan; the value is stored in an Int64.
public override string MakeDurationType(DurationUnit? unit, int precision = 0)
Parameters
unitDurationUnit?precisionint
Returns
MakeEndOfMonth(string)
Renders toLastDayOfMonth(value).
public override string MakeEndOfMonth(string value)
Parameters
valuestring
Returns
MakeFilteredStringAgg(string, string, string)
Renders the filtered string_agg as arrayStringConcat(groupArrayIf(value, predicate), delimiter).
public override string MakeFilteredStringAgg(string value, string delimiter, string predicate)
Parameters
Returns
MakeGroupByTotals(string, KeywordCase)
The super-aggregate WITH TOTALS is a trailing modifier after the grouping list.
public override string MakeGroupByTotals(string grouping, KeywordCase keywordCase = KeywordCase.Lower)
Parameters
groupingstringkeywordCaseKeywordCase
Returns
MakeGrouping(string, GroupingType, KeywordCase)
Renders the trailing with rollup/with cube super-aggregate modifier.
public override string MakeGrouping(string columns, GroupingType groupingType, KeywordCase keywordCase = KeywordCase.Lower)
Parameters
columnsstringgroupingTypeGroupingTypekeywordCaseKeywordCase
Returns
MakeJoinKeyword(JoinType, JoinStrictness, bool, KeywordCase)
Renders [global] [inner|left|right|full|cross] [any|all|asof] join. ClickHouse places the
GLOBAL modifier first and the strictness after the join type, before join. The
LEFT SEMI/LEFT ANTI/PASTE kinds render their own keyword.
public override string MakeJoinKeyword(JoinType joinType, JoinStrictness strictness, bool isGlobal, KeywordCase keywordCase = KeywordCase.Lower)
Parameters
joinTypeJoinTypestrictnessJoinStrictnessisGlobalboolkeywordCaseKeywordCase
Returns
MakeJsonExtract(string, IReadOnlyList<string>)
ClickHouse spells the string-JSON extractors in camel case and the native-JSON functions as
JSONAllPaths/JSONAllPathsWithTypes/toJSONString; JSONLength and
JSONArrayLength return UInt64/Nullable(UInt64), which the row reader cannot
materialise, so they are cast to Int64/Nullable(Int64). The extractors whose
vendor result is a value type but which return NULL for a NULL argument
(JSONExtractUInt, JSONKey, isValidJSON and the simpleJSONExtract*
family) are wrapped in toNullable, so the declared nullable CLR result is a real
Nullable(T) column and a SQL NULL never has to masquerade as the vendor default.
public override string MakeJsonExtract(string name, IReadOnlyList<string> args)
Parameters
namestringargsIReadOnlyList<string>
Returns
MakeLikeEscape(string, KeywordCase)
Omits the ESCAPE clause entirely; a custom escape character is rejected.
public override string MakeLikeEscape(string escapeChar, KeywordCase keywordCase = KeywordCase.Lower)
Parameters
escapeCharstringkeywordCaseKeywordCase
Returns
MakeNow(bool)
Renders now('UTC') for UTC or the server-timezone now() for local time.
public override string MakeNow(bool utc)
Parameters
utcbool
Returns
MakeNullableDurationType(DurationUnit?, int)
ClickHouse's Int64 is not nullable, so a nullable duration column uses Nullable(Int64).
public override string MakeNullableDurationType(DurationUnit? unit, int precision = 0)
Parameters
unitDurationUnit?precisionint
Returns
MakeOrdinal(string, bool)
Renders a string operand normalised for ordinal comparison. A provider with a per-expression
binary collation emits value COLLATE <binary>; a provider whose native String
order is already ordinal (ClickHouse) returns the value unchanged. ignoreCase
additionally case-folds the operand. Only called when SupportsOrdinalComparison is
true.
public override string MakeOrdinal(string value, bool ignoreCase)
Parameters
Returns
MakePage(Paging, StringBuilder, KeywordCase)
Renders limit n offset m, using the maximum unsigned bigint limit for offset-only pages.
public override void MakePage(Paging paging, StringBuilder sqlBuilder, KeywordCase keywordCase = KeywordCase.Lower)
Parameters
pagingPagingsqlBuilderStringBuilderkeywordCaseKeywordCase
MakeParam(string)
Renders a positional parameter as @name.
public override string MakeParam(string name)
Parameters
namestring
Returns
MakeQualifiedTableName(string?, string?, string?, string)
Renders the ClickHouse single-qualifier form database.table. A database and a schema are
the same concept here, so the two overrides are mutually exclusive; a linked server is unsupported.
public override string MakeQualifiedTableName(string? server, string? database, string? schema, string table)
Parameters
Returns
MakeRegexMatch(string, string, bool)
Renders a regular-expression match predicate over the already-rendered value.
pattern is the raw pattern text (the dialect renders and escapes the string
literal itself) and ignoreCase selects
IgnoreCase. Reached only when
SupportsRegex is true.
public override string MakeRegexMatch(string value, string pattern, bool ignoreCase)
Parameters
Returns
MakeRegexReplace(string, string, string, bool)
Renders a regular-expression replace over the already-rendered value,
replacing every match as Replace(string, string, string)
does. pattern and replacement are raw text (the dialect renders
and escapes the literals). Reached only when SupportsRegex is true.
A replacement backreference uses the provider's group syntax (C# $1, SQL \1); it is
not rewritten, so a replacement with a group reference is not portable as written.
public override string MakeRegexReplace(string value, string pattern, string replacement, bool ignoreCase)
Parameters
Returns
MakeRepeat(string, string)
Renders repeat(value, count).
public override string MakeRepeat(string value, string count)
Parameters
Returns
MakeResultColumnType(Type, bool)
ClickHouse's types are not nullable by default, so a Nullable<T> result column is wrapped in Nullable(...).
public override string MakeResultColumnType(Type clrType, bool nullable)
Parameters
Returns
MakeStringAgg(string, string)
Renders arrayStringConcat(groupArray(value), delimiter).
public override string MakeStringAgg(string value, string delimiter)
Parameters
Returns
MakeStringLength(string)
length counts bytes, so lengthUTF8(value) is used to match string.Length.
public override string MakeStringLength(string value)
Parameters
valuestring
Returns
MakeStringPosition(string, string)
position counts bytes, so positionUTF8(value, substring) is used to match string.IndexOf.
protected override string MakeStringPosition(string value, string substring)
Parameters
Returns
MakeStringPosition(string, string, string)
Renders the character-wise positionUTF8(value, substring, start + 1) from a zero-based start.
protected override string MakeStringPosition(string value, string substring, string start)
Parameters
Returns
MakeStringReverse(string)
Renders the character-wise reverseUTF8(value).
protected override string MakeStringReverse(string value)
Parameters
valuestring
Returns
MakeTrim(string, StringTrimKind)
Renders trimLeft, trimRight or trimBoth according to the trim kind.
public override string MakeTrim(string value, StringTrimKind kind)
Parameters
valuestringkindStringTrimKind
Returns
MakeTypeName(Type)
Maps the CLR type to its ClickHouse type name (UInt8, Int16, Int32, Int64, Float32, Float64, Decimal).
public override string MakeTypeName(Type type)
Parameters
typeType
Returns
MakeUpdateHead(string, KeywordCase)
ClickHouse renders the ALTER TABLE ... UPDATE mutation head instead of the ANSI UPDATE ... SET.
public override string MakeUpdateHead(string table, KeywordCase keywordCase = KeywordCase.Lower)
Parameters
tablestringkeywordCaseKeywordCase
Returns
MakeUpdateSuffix(KeywordCase)
Waits for the ClickHouse mutation, so an update is visible to the next statement.
public override string? MakeUpdateSuffix(KeywordCase keywordCase = KeywordCase.Lower)
Parameters
keywordCaseKeywordCase
Returns
MakeWith(bool, KeywordCase)
ClickHouse declares every CTE with with; there is no RECURSIVE keyword.
public override string MakeWith(bool recursive, KeywordCase keywordCase = KeywordCase.Lower)
Parameters
recursiveboolkeywordCaseKeywordCase
Returns
PromoteDateOperand(string, string)
ClickHouse add* on a Date operand truncates the time of day, so a sub-day operand is
promoted to DateTime (or DateTime64 for the sub-second parts).
public override string PromoteDateOperand(string field, string value)
Parameters
Returns
QuoteIdentifier(string)
ClickHouse quotes a physical identifier with backticks, escaping an embedded backslash or backtick.
public override string QuoteIdentifier(string name)
Parameters
namestring
Returns
RenderOrderBy(string, OrderDirection, NullsPosition)
Renders one logical ORDER BY item with an explicit NULL placement. The default emulates the
placement with a CASE rank key whose prefix is always ascending; providers that opt into
SupportsNullsOrdering override it with the native form.
public override string RenderOrderBy(string expressionSql, OrderDirection direction, NullsPosition nullsPosition)
Parameters
expressionSqlstringThe already-qualified, already-quoted key SQL.
directionOrderDirectionThe requested key direction.
nullsPositionNullsPositionThe explicit NULL placement.
Returns
- string
The rendered ordering item.
SupportsDateAddField(string)
ClickHouse 25.8 DateTime64 spans 1900-2299, so a millennium offset cannot be
represented; it is rejected up front instead of being silently clamped. Every other
date_add part defers to the base capability set.
public override bool SupportsDateAddField(string field)
Parameters
fieldstring
Returns
SupportsDatePart(string)
ClickHouse additionally accepts the normalised weekdays and epoch.
public override bool SupportsDatePart(string part)
Parameters
partstring
Returns
SupportsDateTruncField(string)
Accepts the date-trunc fields except decade, century and millennium, which ClickHouse dateTrunc lacks.
public override bool SupportsDateTruncField(string field)
Parameters
fieldstring
Returns
SupportsResultSchema(TableFunctionSchema)
ClickHouse renders the row-derived structure as the leading argument of values.
public override bool SupportsResultSchema(TableFunctionSchema placement)
Parameters
placementTableFunctionSchema
Returns
SupportsTableFunction(string)
ClickHouse provides the numbers/numbers_mt, zeros/zeros_mt and
generateRandom table functions plus the server/cluster table functions url,
s3, file, remote, remoteSecure, cluster and
clusterAllReplicas.
public override bool SupportsTableFunction(string name)
Parameters
namestring
Returns
WrapCount(string, bool)
Casts the count expression to Int64 for the large form and Int32 otherwise.
public override string WrapCount(string countExpression, bool big)
Parameters
Returns
WrapIntegerWindowResult(string)
Casts a ranking window-function expression to Int32 so it maps to the declared int.
public override string WrapIntegerWindowResult(string windowExpression)
Parameters
windowExpressionstring
Returns
WrapTableFunction(string, string)
numbers/numbers_mt expose an unsigned UInt64 number column; cast it to
Int64 through a wrapping subquery to match INumbersRow.Value. The built-in
generateRandom gets its fixed structure injected here and its id column cast the
same way.
public override string WrapTableFunction(string name, string call)