Table of Contents

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

serverVersion Version

The ClickHouse server version this dialect declares.

Exceptions

ArgumentNullException

serverVersion is 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

ClickHouseDialect

Properties

AggregateFilterStyle

ClickHouse renders an aggregate filter as the -If combinator (sumIf, countIf).

public override AggregateFilterStyle AggregateFilterStyle { get; }

Property Value

AggregateFilterStyle

ArrayJoinClause

ClickHouse implements the ARRAY JOIN clause.

public override IArrayJoinRenderer ArrayJoinClause { get; }

Property Value

IArrayJoinRenderer

ClickHouseAggregates

ClickHouse implements the ClickHouse-only aggregate catalogue (statistical, quantile-algorithm, array/tuple and time-series aggregates).

public override IClickHouseAggregateRenderer ClickHouseAggregates { get; }

Property Value

IClickHouseAggregateRenderer

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

IDateConversionRenderer

DeleteRequiresWhere

ClickHouse's ALTER TABLE ... DELETE mutation requires a WHERE clause.

public override bool DeleteRequiresWhere { get; }

Property Value

bool

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

IExtremeRowRenderer

Iif

ClickHouse renders the portable iif as if(condition, whenTrue, whenFalse).

public override IIifRenderer Iif { get; }

Property Value

IIifRenderer

LimitBy

ClickHouse implements LIMIT n BY expr.

public override ILimitByRenderer LimitBy { get; }

Property Value

ILimitByRenderer

MultiIf

ClickHouse implements the multi-branch conditional multiIf(cond1, then1, ..., else).

public override IMultiIfRenderer MultiIf { get; }

Property Value

IMultiIfRenderer

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

Type

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

INullSafeComparisonRenderer

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

IReadOnlyList<KeyValuePair<string, string>>

QuantileAggregates

ClickHouse implements the parameterised quantile(level)(value) family and median.

public override IQuantileAggregateRenderer QuantileAggregates { get; }

Property Value

IQuantileAggregateRenderer

RequireSubqueryAlias

A ClickHouse derived table (subquery in FROM) must have an alias.

public override bool RequireSubqueryAlias { get; }

Property Value

bool

ScalarFunctions

ClickHouse renders every cross-provider scalar function (UTF-8 character-wise where it matters).

public override IScalarFunctions ScalarFunctions { get; }

Property Value

IScalarFunctions

SequenceAggregates

ClickHouse implements the windowFunnel/retention/sequenceMatch aggregates.

public override ISequenceAggregateRenderer SequenceAggregates { get; }

Property Value

ISequenceAggregateRenderer

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

ISessionInfoFunctions

StringFormats

ClickHouse renders CLR format specifiers through format/formatDateTime.

public override IStringFormatFunctions? StringFormats { get; }

Property Value

IStringFormatFunctions

StringSplit

ClickHouse renders string.Split as splitByChar(separator, value).

public override IStringSplitRenderer StringSplit { get; }

Property Value

IStringSplitRenderer

SupportsAnyLastAggregate

ClickHouse implements the any/anyLast row-picking aggregates.

public override bool SupportsAnyLastAggregate { get; }

Property Value

bool

SupportsAnyValueAggregate

ClickHouse renders the arbitrary-value aggregate as any(x).

public override bool SupportsAnyValueAggregate { get; }

Property Value

bool

SupportsArgMinMax

ClickHouse implements the argMin/argMax aggregates.

public override bool SupportsArgMinMax { get; }

Property Value

bool

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

bool

SupportsArrayJoin

ClickHouse implements arrayJoin(array), which expands one row per element.

public override bool SupportsArrayJoin { get; }

Property Value

bool

SupportsBitAggregates

ClickHouse implements the bit aggregates as groupBitAnd/groupBitOr/groupBitXor.

public override bool SupportsBitAggregates { get; }

Property Value

bool

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

bool

SupportsCollation

ClickHouse has no COLLATE clause.

public override bool SupportsCollation { get; }

Property Value

bool

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

bool

SupportsCreateTableAsSelect

ClickHouse materialises a query into a persistent table with CREATE TABLE ... ENGINE = ... AS SELECT.

public override bool SupportsCreateTableAsSelect { get; }

Property Value

bool

SupportsCreateTableAsSelectIfNotExists

ClickHouse accepts IF NOT EXISTS on CREATE TABLE ... AS SELECT.

public override bool SupportsCreateTableAsSelectIfNotExists { get; }

Property Value

bool

SupportsCrossDatabase

ClickHouse qualifies a table with a database name (db.table); there is no separate schema level.

public override bool SupportsCrossDatabase { get; }

Property Value

bool

SupportsCube

ClickHouse spells CUBE as the trailing modifier GROUP BY ... WITH CUBE.

public override bool SupportsCube { get; }

Property Value

bool

SupportsDateArithmetic

ClickHouse implements date arithmetic through its addYears/.../addSeconds family.

public override bool SupportsDateArithmetic { get; }

Property Value

bool

SupportsDateTimeOffsetTranslation

ClickHouse stores a DateTimeOffset as a UTC-normalized DateTime64, so DTO operations are supported.

public override bool SupportsDateTimeOffsetTranslation { get; }

Property Value

bool

SupportsDateTrunc

ClickHouse implements date truncation through dateTrunc(unit, value).

public override bool SupportsDateTrunc { get; }

Property Value

bool

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

bool

SupportsFinal

ClickHouse implements the FINAL table modifier.

public override bool SupportsFinal { get; }

Property Value

bool

SupportsGlobalJoin

ClickHouse implements the GLOBAL join modifier.

public override bool SupportsGlobalJoin { get; }

Property Value

bool

SupportsGlobalPredicates

ClickHouse implements the distributed GLOBAL IN predicate.

public override bool SupportsGlobalPredicates { get; }

Property Value

bool

SupportsGreatestLeast

ClickHouse renders the standard greatest(...)/least(...) functions.

public override bool SupportsGreatestLeast { get; }

Property Value

bool

SupportsGroupByWithTotals

ClickHouse implements the GROUP BY ... WITH TOTALS modifier.

public override bool SupportsGroupByWithTotals { get; }

Property Value

bool

SupportsGroupingSets

ClickHouse supports GROUP BY GROUPING SETS (...).

public override bool SupportsGroupingSets { get; }

Property Value

bool

SupportsHigherOrderArrayFunctions

ClickHouse implements the higher-order (lambda) array functions (arrayMap, arrayFilter, arrayExists, arrayAll, arrayCount, arrayFirst*, arrayLast*).

public override bool SupportsHigherOrderArrayFunctions { get; }

Property Value

bool

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

bool

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

bool

SupportsIntersectExceptAll

ClickHouse implements the INTERSECT ALL/EXCEPT ALL set-operation variants.

public override bool SupportsIntersectExceptAll { get; }

Property Value

bool

SupportsJoinStrictness

ClickHouse implements the ANY/ALL/ASOF join modifiers.

public override bool SupportsJoinStrictness { get; }

Property Value

bool

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

bool

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

bool

SupportsNamedWindows

ClickHouse declares named windows (WINDOW w AS (...)) and references them with OVER w.

public override bool SupportsNamedWindows { get; }

Property Value

bool

SupportsNthValue

ClickHouse implements the nth_value(value, n) window function.

public override bool SupportsNthValue { get; }

Property Value

bool

SupportsNullsOrdering

ClickHouse renders the native NULLS FIRST/NULLS LAST ordering modifier.

public override bool SupportsNullsOrdering { get; }

Property Value

bool

SupportsOrdinalComparison

ClickHouse's native String order is byte-order, so ordinal comparison is native.

public override bool SupportsOrdinalComparison { get; }

Property Value

bool

SupportsPasteJoin

ClickHouse implements the PASTE join kind.

public override bool SupportsPasteJoin { get; }

Property Value

bool

SupportsPercentRankCumeDist

ClickHouse implements the percent_rank/cume_dist window functions.

public override bool SupportsPercentRankCumeDist { get; }

Property Value

bool

SupportsPreWhere

ClickHouse implements the PREWHERE clause.

public override bool SupportsPreWhere { get; }

Property Value

bool

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

bool

SupportsRawSqlSource

ClickHouse supports a raw SQL derived table (FROM (<sql>) AS alias).

public override bool SupportsRawSqlSource { get; }

Property Value

bool

SupportsRecursiveCte

ClickHouse has no recursive WITH, so the new typed recursive CTE API fails closed.

public override bool SupportsRecursiveCte { get; }

Property Value

bool

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

bool

SupportsRegex

ClickHouse matches with the RE2-based match and replaces with replaceRegexpAll.

public override bool SupportsRegex { get; }

Property Value

bool

SupportsRollup

ClickHouse spells ROLLUP as the trailing modifier GROUP BY ... WITH ROLLUP.

public override bool SupportsRollup { get; }

Property Value

bool

SupportsSample

ClickHouse implements the SAMPLE table modifier.

public override bool SupportsSample { get; }

Property Value

bool

SupportsSelectWhereMinMax

ClickHouse 21+ renders SelectWhereMax/SelectWhereMin with a window function.

public override bool SupportsSelectWhereMinMax { get; }

Property Value

bool

SupportsSemiAntiJoin

ClickHouse implements the LEFT SEMI/LEFT ANTI join kinds.

public override bool SupportsSemiAntiJoin { get; }

Property Value

bool

SupportsSettings

ClickHouse implements the trailing SETTINGS clause.

public override bool SupportsSettings { get; }

Property Value

bool

SupportsStatisticalAggregates

ClickHouse implements the statistical aggregates as corr/covarPop/covarSamp.

public override bool SupportsStatisticalAggregates { get; }

Property Value

bool

SupportsStringAgg

ClickHouse renders string_agg through arrayStringConcat(groupArray(value), delimiter); array_agg stays unavailable.

public override bool SupportsStringAgg { get; }

Property Value

bool

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

bool

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

bool

SupportsTransactions

ClickHouse is false because its HTTP protocol has no ADO.NET transaction.

public override bool SupportsTransactions { get; }

Property Value

bool

SupportsTruncate

ClickHouse has a native synchronous TRUNCATE TABLE.

public override bool SupportsTruncate { get; }

Property Value

bool

SupportsWindowFrameGroups

ClickHouse supports the GROUPS window frame unit.

public override bool SupportsWindowFrameGroups { get; }

Property Value

bool

TopKAggregates

ClickHouse implements the parameterised topK(N)(value)/topKWeighted(N)(value, weight) aggregates.

public override ITopKAggregateRenderer TopKAggregates { get; }

Property Value

ITopKAggregateRenderer

Tuple

ClickHouse has a native Tuple(...) type and implements the tuple constructor and tupleElement access.

public override ITupleRenderer? Tuple { get; }

Property Value

ITupleRenderer

UniqAggregates

ClickHouse implements the distinct-count uniq* aggregates.

public override IUniqAggregateRenderer UniqAggregates { get; }

Property Value

IUniqAggregateRenderer

UpdateRequiresWhere

ClickHouse's ALTER TABLE ... UPDATE mutation requires a WHERE clause.

public override bool UpdateRequiresWhere { get; }

Property Value

bool

UuidGenerators

ClickHouse renders both UUID generators.

public override IUuidGenerators UuidGenerators { get; }

Property Value

IUuidGenerators

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

bool

WrapsCountResult

ClickHouse's count/countIf return UInt64, so the result is cast to the declared CLR type.

public override bool WrapsCountResult { get; }

Property Value

bool

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

keyword string

Returns

string

MakeAggregate(string)

Maps the portable aggregate name to its ClickHouse spelling (for example stdev to stddevSamp).

public override string MakeAggregate(string name)

Parameters

name string

Returns

string

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

name string
call string

Returns

string

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

name string
call string
resultType Type

Returns

string

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

aggregate string
argument string
filterPredicate string
windowClause string

Returns

string

MakeBool(bool)

ClickHouse has a native boolean type, rendered as true/false.

public override string MakeBool(bool v)

Parameters

v bool

Returns

string

MakeCoalesce(string, string)

Renders the standard coalesce(v1, v2).

public override string MakeCoalesce(string v1, string v2)

Parameters

v1 string
v2 string

Returns

string

MakeColumnReference(string)

ClickHouse uses the backtick-quoted identifier for references as well.

public override string MakeColumnReference(string name)

Parameters

name string

Returns

string

MakeConcat(IReadOnlyList<string>)

ClickHouse concatenates with the concat(part, ...) function rather than the + operator.

public override string MakeConcat(IReadOnlyList<string> parts)

Parameters

parts IReadOnlyList<string>

Returns

string

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

clause CreateTableAsClause
selectSql string
keywordCase KeywordCase

Returns

string

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

field string
amount string
value string

Returns

string

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

field string
amount string
value string
isDateTimeOffset bool

Returns

string

MakeDateDiff(string, string, string)

ClickHouse computes date differences through dateDiff(unit, start, end).

public override string MakeDateDiff(string field, string start, string end)

Parameters

field string
start string
end string

Returns

string

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

field string
start string
end string

Returns

string

MakeDateFromParts(string, string, string)

Renders makeDate(year, month, day).

public override string MakeDateFromParts(string year, string month, string day)

Parameters

year string
month string
day string

Returns

string

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

part string
value string

Returns

string

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

part string
value string
isDateTimeOffset bool

Returns

string

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

utc bool

Returns

string

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

field string
value string

Returns

string

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

table string
keywordCase KeywordCase

Returns

string

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

keywordCase KeywordCase

Returns

string

MakeDictionaryFunction(string, IReadOnlyList<string>)

ClickHouse spells the dictionary and region functions in camel case.

public override string MakeDictionaryFunction(string name, IReadOnlyList<string> args)

Parameters

name string
args IReadOnlyList<string>

Returns

string

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

unit DurationUnit?
precision int

Returns

string

MakeEndOfMonth(string)

Renders toLastDayOfMonth(value).

public override string MakeEndOfMonth(string value)

Parameters

value string

Returns

string

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

value string
delimiter string
predicate string

Returns

string

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

grouping string
keywordCase KeywordCase

Returns

string

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

columns string
groupingType GroupingType
keywordCase KeywordCase

Returns

string

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

joinType JoinType
strictness JoinStrictness
isGlobal bool
keywordCase KeywordCase

Returns

string

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

name string
args IReadOnlyList<string>

Returns

string

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

escapeChar string
keywordCase KeywordCase

Returns

string

MakeNow(bool)

Renders now('UTC') for UTC or the server-timezone now() for local time.

public override string MakeNow(bool utc)

Parameters

utc bool

Returns

string

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

unit DurationUnit?
precision int

Returns

string

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

value string
ignoreCase bool

Returns

string

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

paging Paging
sqlBuilder StringBuilder
keywordCase KeywordCase

MakeParam(string)

Renders a positional parameter as @name.

public override string MakeParam(string name)

Parameters

name string

Returns

string

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

server string
database string
schema string
table string

Returns

string

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

value string
pattern string
ignoreCase bool

Returns

string

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

value string
pattern string
replacement string
ignoreCase bool

Returns

string

MakeRepeat(string, string)

Renders repeat(value, count).

public override string MakeRepeat(string value, string count)

Parameters

value string
count string

Returns

string

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

clrType Type
nullable bool

Returns

string

MakeStringAgg(string, string)

Renders arrayStringConcat(groupArray(value), delimiter).

public override string MakeStringAgg(string value, string delimiter)

Parameters

value string
delimiter string

Returns

string

MakeStringLength(string)

length counts bytes, so lengthUTF8(value) is used to match string.Length.

public override string MakeStringLength(string value)

Parameters

value string

Returns

string

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

value string
substring string

Returns

string

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

value string
substring string
start string

Returns

string

MakeStringReverse(string)

Renders the character-wise reverseUTF8(value).

protected override string MakeStringReverse(string value)

Parameters

value string

Returns

string

MakeTrim(string, StringTrimKind)

Renders trimLeft, trimRight or trimBoth according to the trim kind.

public override string MakeTrim(string value, StringTrimKind kind)

Parameters

value string
kind StringTrimKind

Returns

string

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

type Type

Returns

string

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

table string
keywordCase KeywordCase

Returns

string

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

keywordCase KeywordCase

Returns

string

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

recursive bool
keywordCase KeywordCase

Returns

string

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

field string
value string

Returns

string

QuoteIdentifier(string)

ClickHouse quotes a physical identifier with backticks, escaping an embedded backslash or backtick.

public override string QuoteIdentifier(string name)

Parameters

name string

Returns

string

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

expressionSql string

The already-qualified, already-quoted key SQL.

direction OrderDirection

The requested key direction.

nullsPosition NullsPosition

The 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

field string

Returns

bool

SupportsDatePart(string)

ClickHouse additionally accepts the normalised weekdays and epoch.

public override bool SupportsDatePart(string part)

Parameters

part string

Returns

bool

SupportsDateTruncField(string)

Accepts the date-trunc fields except decade, century and millennium, which ClickHouse dateTrunc lacks.

public override bool SupportsDateTruncField(string field)

Parameters

field string

Returns

bool

SupportsResultSchema(TableFunctionSchema)

ClickHouse renders the row-derived structure as the leading argument of values.

public override bool SupportsResultSchema(TableFunctionSchema placement)

Parameters

placement TableFunctionSchema

Returns

bool

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

name string

Returns

bool

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

countExpression string
big bool

Returns

string

WrapIntegerWindowResult(string)

Casts a ranking window-function expression to Int32 so it maps to the declared int.

public override string WrapIntegerWindowResult(string windowExpression)

Parameters

windowExpression string

Returns

string

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)

Parameters

name string
call string

Returns

string