Package

slick

compiler

Permalink

package compiler

Slick AST to database query compiler

Source
package.scala
Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. compiler
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Type Members

  1. class AssignUniqueSymbols extends Phase

    Permalink

    Ensure that all symbol definitions in a tree are unique.

    Ensure that all symbol definitions in a tree are unique. The same symbol can initially occur in multiple sub-trees when some part of a query is reused multiple times. This phase assigns new, uniqe symbols, so that later phases do not have to take scopes into account for identifying the source of a symbol. The rewriting is performed for both, term symbols and type symbols.

    The phase state is a collection of flags depending on the presence or absence of certain node types in the AST. This information can be used to selectively skip later compiler phases when it is already known that there is nothing for them to translate.

  2. abstract class CodeGen extends Phase

    Permalink

    A standard skeleton for a code generator phase.

  3. class CompilerState extends AnyRef

    Permalink

    The current state of a compiler run, consisting of the current AST and additional immutable state of individual phases.

    The current state of a compiler run, consisting of the current AST and additional immutable state of individual phases. Mutability is confined to the SymbolNamer. The state is tied to a specific compiler instance so that phases can call back into the compiler.

  4. class CreateAggregates extends Phase

    Permalink

    Rewrite aggregation function calls to Aggregate nodes.

  5. class CreateResultSetMapping extends Phase

    Permalink

    Create a ResultSetMapping root node, ensure that the top-level server-side node returns a collection, and hoist client-side type conversions into the ResultSetMapping.

    Create a ResultSetMapping root node, ensure that the top-level server-side node returns a collection, and hoist client-side type conversions into the ResultSetMapping. The original result type (which was removed by removeMappedTypes) is assigned back to the top level.

  6. class EmulateOuterJoins extends Phase

    Permalink

    An optional phase which rewrites outer joins into more commonly supported operations for use on databases that lack outer join support.

    An optional phase which rewrites outer joins into more commonly supported operations for use on databases that lack outer join support.

    Full outer joins are always emulated. Right joins can be replaced by left joins (or an emulated version thereof). Left joins can be emulated with inner joins and unions.

  7. class ExpandRecords extends Phase

    Permalink

    Expand paths of record types to reference all fields individually and recreate the record structure at the call site.

  8. class ExpandSums extends Phase

    Permalink

    Expand sum types and their catamorphisms to equivalent product type operations.

  9. class ExpandTables extends Phase

    Permalink

    Expand table-valued expressions in the result type to their star projection and compute the missing structural expansions of table types.

    Expand table-valued expressions in the result type to their star projection and compute the missing structural expansions of table types. After this phase the AST should always be well-typed.

  10. class FixRowNumberOrdering extends Phase

    Permalink

    Inject the proper orderings into the RowNumber nodes produced earlier by the resolveFixJoins phase.

  11. class FlattenProjections extends Phase

    Permalink

    Flatten all Pure node contents into a single StructNode.

    Flatten all Pure node contents into a single StructNode.

    After this phase, all Pure nodes produce a StructNode of primitive fields. As a side-effect, nested NominalTypes are eliminated.

  12. class ForceOuterBinds extends Phase

    Permalink

    Ensure that all collection operations are wrapped in a Bind so that we have a place for expanding references later.

    Ensure that all collection operations are wrapped in a Bind so that we have a place for expanding references later. FilteredQueries are allowed on top of collection operations without a Bind in between, unless that operation is a Join, Pure or Distinct node.

  13. class HoistClientOps extends Phase

    Permalink

    Lift applicable operations at the top level to the client side.

  14. class InferTypes extends Phase

    Permalink

    Infer all missing types.

  15. class InsertCompiler extends Phase

    Permalink

    A custom compiler for INSERT statements.

    A custom compiler for INSERT statements. We could reuse the standard phases with a minor modification instead, but this is much faster.

  16. class MergeToComprehensions extends Phase

    Permalink

    This phase merges nested nodes of types Bind, Filter, GroupBy, SortBy, Take, Drop, CollectionCast and Distinct to Comprehension nodes.

    This phase merges nested nodes of types Bind, Filter, GroupBy, SortBy, Take, Drop, CollectionCast and Distinct to Comprehension nodes. Nodes can be merged if they occur in the following order:

    [Source] -> Filter (where) -> GroupBy -> SortBy / (Distinct | Filter (having)) -> Take / Drop

    Aliasing Binds and CollectionCasts are allowed everywhere in the chain. Any out of order operation starts a new chain with a subquery as the source.

  17. class OptimizeScalar extends Phase

    Permalink

    Optimize scalar expressions

  18. trait Phase extends (CompilerState) ⇒ CompilerState with Logging

    Permalink

    A phase of the query compiler, identified by a unique name

  19. class PruneProjections extends Phase

    Permalink

    Remove unreferenced fields from StructNodes.

  20. class QueryCompiler extends Logging

    Permalink

    An immutable, stateless query compiler consisting of a series of phases

  21. class RelabelUnions extends Phase

    Permalink

    Assign the AnonSymbols of fields from the left side of a Union to the right side.

    Assign the AnonSymbols of fields from the left side of a Union to the right side. This ensures that both sides are protected when we prune unused references pointing to left-side Symbols.

  22. class RemoveFieldNames extends Phase

    Permalink

    Convert unreferenced StructNodes to single columns or ProductNodes (which is needed for aggregation functions and at the top level).

  23. class RemoveMappedTypes extends Phase

    Permalink

    Remove all mapped types from the tree and store the original top-level type as the phase state to be used later for building the ResultSetMapping.

  24. class RemoveTakeDrop extends Phase

    Permalink

    Replace all occurrences of Take and Drop with row number computations based on zipWithIndex operations.

  25. class ReorderOperations extends Phase

    Permalink

    Reorder certain stream operations for more efficient merging in mergeToComprehensions.

  26. class ResolveZipJoins extends Phase

    Permalink

    Rewrite zip joins into a form suitable for SQL using inner joins and RowNumber columns.

    Rewrite zip joins into a form suitable for SQL using inner joins and RowNumber columns.

    We rely on having a Bind around every Join and both of its generators, which should have been generated by Phase.forceOuterBinds. The inner Binds need to select Pure(StructNode(...)) which should be the outcome of Phase.flattenProjections.

  27. class RewriteBooleans extends Phase

    Permalink

    For SQL back-ends which do not support real boolean types for fields and general expressions but which do have special boolean expressions and operators, this phase injects conversions between fake and real boolean values.

    For SQL back-ends which do not support real boolean types for fields and general expressions but which do have special boolean expressions and operators, this phase injects conversions between fake and real boolean values.

    The default for booleans in the AST is to use the fake type (mapped to a numeric type by the profile). There are specific places where a real boolean (that can be used in boolean expressions) is required or produced, so we inject a call to ToRealBoolean or ToFakeBoolean as needed.

  28. class RewriteDistinct extends Phase

    Permalink

    Rewrite "distinct on" to "distinct" or "group by"

  29. class RewriteJoins extends Phase

    Permalink

    Rewrite monadic joins to applicative joins.

    Rewrite monadic joins to applicative joins. After this phase all Bind nodes are of the form Bind(_, _, Pure(_, _)) (i.e. flatMap has been reduced to map).

  30. class SpecializeParameters extends Phase

    Permalink

    Specialize the AST for edge cases of query parameters.

    Specialize the AST for edge cases of query parameters. This is required for compiling take(0) for some databases which do not allow LIMIT 0.

  31. class UnrollTailBinds extends Phase

    Permalink
  32. case class UsedFeatures(distinct: Boolean, typeMapping: Boolean, aggregate: Boolean, nonPrimitiveOption: Boolean) extends Product with Serializable

    Permalink
  33. class VerifySymbols extends Phase

    Permalink

    Verify that all monadic joins have been transformed into applicative joins and that the resulting tree does not contain references to unreachable symbols.

  34. class VerifyTypes extends Phase

    Permalink

    Optional phase which verifies that retyping the tree does not change any types.

    Optional phase which verifies that retyping the tree does not change any types. Useful for debugging type-related problems with large trees.

Value Members

  1. object CodeGen

    Permalink
  2. object InsertCompiler

    Permalink
  3. object Phase

    Permalink

    The Phase companion objects contains ready-to-use Phase objects for the standard phases of the query compiler

  4. object QueryCompiler

    Permalink
  5. object RewriteBooleans

    Permalink

Inherited from AnyRef

Inherited from Any

Ungrouped