DBX-6700 Query-based compiler & Multifile support#870
Open
huydo862003 wants to merge 161 commits into
Open
Conversation
4c6b1e9 to
3c13735
Compare
988255d to
6223528
Compare
6e8458e to
1f4a6ad
Compare
huyleminh01
reviewed
May 11, 2026
Contributor
There was a problem hiding this comment.
I would like to write the selective import in a single line. Can I do it like this?
// types.dbml
Enum job_status1 {
pending running done
}
Enum job_status2 {
pending running done
}
// And many table definitions here
// jobs.dbml
use {
enum job_status1, enum job_status2
} from './types'
Contributor
Author
There was a problem hiding this comment.
👀 hmm currently it's not possible, as I intentionally use the same syntax like other elements' body (fields separated by newlines) for consistency. 🤔
Coverage ReportCommit: 6cea757 Overall Coverage
Package Coverage
|
| File | Lines | Statements | Functions | Branches |
|---|---|---|---|---|
src/connectors/bigquery/index.ts |
0.00% | 0.00% | 0.00% | 0.00% |
src/utils/credential-loader.ts |
0.00% | 0.00% | 0.00% | 0.00% |
src/utils/helpers.ts |
0.00% | 0.00% | 0.00% | 0.00% |
src/connectors/snowflake/index.ts |
10.56% | 10.31% | 0.00% | 0.00% |
src/utils/parseSchema.ts |
46.15% | 42.85% | 28.57% | 27.27% |
src/connectors/connector.ts |
66.66% | 66.66% | 100.00% | 57.14% |
src/connectors/oracle/tables.ts |
71.25% | 67.39% | 100.00% | 56.96% |
src/connectors/oracle/index.ts |
80.00% | 80.76% | 100.00% | 25.00% |
src/connectors/oracle/utils.ts |
85.71% | 85.71% | 100.00% | 71.42% |
@dbml/dbml-parse
80 file(s) below 80% coverage
| File | Lines | Statements | Functions | Branches |
|---|---|---|---|---|
src/compiler/queries/container/scope.ts |
0.00% | 0.00% | 0.00% | 0.00% |
src/services/diagnostics/provider.ts |
0.00% | 0.00% | 0.00% | 0.00% |
src/compiler/queries/pipeline/interpret.ts |
18.91% | 21.95% | 75.00% | 42.85% |
src/services/suggestions/crossFile.ts |
19.35% | 19.44% | 33.33% | 10.00% |
src/core/local_modules/enum/index.ts |
48.00% | 46.29% | 57.14% | 52.63% |
src/core/global_modules/project/interpret.ts |
52.50% | 46.66% | 83.33% | 23.07% |
src/compiler/projectLayout/layout.ts |
54.16% | 53.84% | 75.00% | 52.63% |
src/core/local_modules/ref/index.ts |
62.50% | 61.76% | 100.00% | 57.14% |
src/core/types/symbol/symbols.ts |
62.54% | 55.03% | 59.83% | 45.77% |
src/core/global_modules/records/utils/data/values.ts |
63.30% | 55.71% | 72.72% | 49.28% |
src/core/local_modules/tableGroup/validate.ts |
64.10% | 64.44% | 71.42% | 58.00% |
src/compiler/queries/legacy/token.ts |
66.66% | 66.66% | 66.66% | 100.00% |
src/core/global_modules/enum/bind.ts |
66.66% | 68.75% | 83.33% | 50.00% |
src/core/local_modules/program/index.ts |
66.66% | 69.23% | 75.00% | 62.50% |
src/core/global_modules/note/bind.ts |
69.23% | 71.42% | 83.33% | 50.00% |
src/core/local_modules/checks/index.ts |
69.23% | 75.00% | 100.00% | 64.28% |
src/core/local_modules/project/index.ts |
69.23% | 69.23% | 100.00% | 63.63% |
src/core/local_modules/custom/index.ts |
70.58% | 71.42% | 80.00% | 68.75% |
src/core/types/report.ts |
70.83% | 66.66% | 83.33% | 71.42% |
src/compiler/queries/legacy/parse.ts |
72.22% | 61.90% | 66.66% | 33.33% |
src/core/local_modules/tablePartial/validate.ts |
73.01% | 71.83% | 79.22% | 57.67% |
src/compiler/queries/utils.ts |
73.10% | 73.38% | 90.90% | 51.11% |
src/core/global_modules/project/bind.ts |
73.33% | 75.00% | 100.00% | 50.00% |
src/core/local_modules/note/validate.ts |
73.52% | 70.27% | 76.92% | 66.66% |
src/core/local_modules/indexes/index.ts |
73.68% | 69.35% | 63.63% | 64.28% |
src/core/local_modules/indexes/validate.ts |
73.91% | 74.66% | 90.90% | 56.00% |
src/core/local_modules/use/index.ts |
73.91% | 75.00% | 75.00% | 81.25% |
src/core/local_modules/note/index.ts |
75.00% | 75.86% | 75.00% | 72.72% |
src/core/local_modules/project/validate.ts |
75.00% | 75.86% | 100.00% | 56.25% |
src/services/suggestions/utils/index.ts |
75.00% | 75.00% | 100.00% | 60.71% |
src/core/local_modules/records/index.ts |
75.60% | 76.19% | 100.00% | 68.08% |
src/core/global_modules/records/utils/data/sqlTypes.ts |
76.59% | 80.64% | 82.35% | 72.22% |
src/core/global_modules/utils.ts |
78.57% | 75.55% | 62.50% | 65.11% |
src/core/global_modules/tableGroup/bind.ts |
79.31% | 80.00% | 100.00% | 57.14% |
src/core/types/filepath.ts |
79.48% | 78.57% | 77.77% | 70.37% |
src/core/global_modules/indexes/bind.ts |
80.00% | 78.37% | 90.00% | 73.07% |
src/core/global_modules/program/utils.ts |
80.00% | 80.00% | 100.00% | 70.00% |
src/core/local_modules/records/validate.ts |
80.00% | 80.55% | 93.75% | 72.30% |
src/core/local_modules/checks/validate.ts |
81.25% | 82.69% | 93.75% | 70.00% |
src/core/local_modules/diagramView/validate.ts |
81.33% | 78.04% | 84.21% | 72.72% |
src/core/global_modules/indexes/interpret.ts |
81.39% | 72.00% | 100.00% | 56.66% |
src/core/local_modules/tablePartial/index.ts |
81.48% | 81.48% | 100.00% | 77.27% |
src/core/global_modules/records/bind.ts |
82.92% | 83.72% | 93.75% | 67.30% |
src/compiler/queries/container/token.ts |
83.33% | 85.71% | 100.00% | 75.00% |
src/core/global_modules/ref/bind.ts |
83.33% | 83.87% | 90.00% | 75.00% |
src/core/parser/parser.ts |
83.86% | 84.09% | 100.00% | 74.35% |
__tests__/utils/compiler.ts |
84.28% | 82.25% | 100.00% | 58.11% |
src/core/global_modules/records/utils/constraints/pk.ts |
84.61% | 81.42% | 92.59% | 56.52% |
src/core/local_modules/table/validate.ts |
85.23% | 85.80% | 90.24% | 74.11% |
src/core/local_modules/enum/validate.ts |
85.24% | 81.81% | 81.25% | 76.31% |
__tests__/utils/mocks.ts |
85.71% | 86.20% | 75.00% | 100.00% |
src/core/global_modules/use/index.ts |
86.31% | 82.11% | 100.00% | 77.04% |
src/core/global_modules/tablePartial/bind.ts |
86.79% | 87.27% | 100.00% | 71.42% |
src/services/suggestions/utils/useMerger.ts |
86.95% | 81.13% | 100.00% | 46.34% |
src/core/global_modules/tableGroup/interpret.ts |
88.09% | 88.37% | 100.00% | 77.27% |
src/core/global_modules/tablePartial/interpret.ts |
88.29% | 80.73% | 84.21% | 67.16% |
src/services/suggestions/recordRowSnippet.ts |
88.46% | 87.09% | 100.00% | 73.80% |
src/compiler/queries/nodeAtPosition.ts |
88.88% | 90.00% | 100.00% | 75.00% |
src/core/global_modules/diagramView/index.ts |
89.16% | 86.23% | 83.33% | 78.18% |
src/compiler/index.ts |
89.74% | 89.91% | 75.00% | 75.60% |
src/services/suggestions/provider.ts |
89.84% | 85.91% | 98.38% | 78.06% |
src/core/global_modules/table/interpret.ts |
90.62% | 84.72% | 95.45% | 67.70% |
src/core/global_modules/records/index.ts |
90.90% | 87.15% | 100.00% | 79.16% |
src/core/global_modules/schema/index.ts |
92.26% | 82.46% | 91.66% | 70.07% |
src/core/utils/interpret.ts |
92.98% | 89.47% | 100.00% | 73.13% |
src/core/types/symbol/metadata.ts |
94.24% | 80.17% | 97.56% | 64.67% |
src/core/global_modules/diagramView/interpret.ts |
94.49% | 90.32% | 92.85% | 75.25% |
src/services/suggestions/use.ts |
94.84% | 87.39% | 100.00% | 75.00% |
src/core/global_modules/note/interpret.ts |
95.23% | 95.45% | 100.00% | 66.66% |
src/core/global_modules/ref/interpret.ts |
95.45% | 95.65% | 100.00% | 79.16% |
src/core/global_modules/records/interpret.ts |
95.97% | 92.59% | 100.00% | 79.54% |
__tests__/examples/interpreter/multifile/utils.ts |
96.00% | 89.65% | 100.00% | 62.50% |
src/compiler/queries/canonicalName.ts |
96.96% | 92.10% | 100.00% | 76.66% |
src/core/global_modules/program/interpret.ts |
97.07% | 91.45% | 100.00% | 70.31% |
src/core/types/errors.ts |
98.44% | 98.46% | 66.66% | 100.00% |
src/compiler/queries/transform/renameTable.ts |
99.05% | 90.47% | 100.00% | 78.82% |
src/core/global_modules/checks/interpret.ts |
100.00% | 88.88% | 100.00% | 60.00% |
src/core/global_modules/program/index.ts |
100.00% | 84.84% | 100.00% | 75.00% |
src/core/global_modules/records/utils/constraints/unique.ts |
100.00% | 95.00% | 100.00% | 62.50% |
src/services/definition/provider.ts |
100.00% | 95.83% | 100.00% | 75.00% |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
BREAKING CHANGE: Revamp the compiler into query-based design.
Add multifile support into compiler:
use: Non-transitive importsreuse: Transitive importsTable,Enum,TableGroup,Schema,Note(sticky note),TablePartialRef,Recordsare automatically pulled if all of its tables are in scope.TableGroupimport would also import all of its tables.TableGroupcannot reference imported table, it can only reference the current file's table (for now).Schemaimport would pull all elements inside that schema into scope.Discussion: [Proposal] Support splitting DBML to multiple files #843
TDD:
Suggested review order
Filepath,SyntaxNode,NodeSymboland the internable typesInternable.compiler.tsfile:a. Check how the local cache & the global cache are setup (
localQueryandglobalQuerymethods).b. Check what queries we have: https://www.notion.so/holistics/TDD-94-Query-based-compiler-Overview-of-the-compiler-architecture-345f89dc7e4980e88bc9fd6d140c1d8b?v=b4c7e791a9664e779faf139f7f7bda40&source=copy_link#345f89dc7e49804f8f0edca6282a32c8
lexer,parser.local_modulesfor validator (do not care about multifile support yet).global_modulesfor binder and interpreter (do not care about multifile support yet).use.Issue
(issue link here)
Lasting Changes (Technical)
(please list down: code changes/things that have wide-effect; new libraries/functions added that can be used by others; examples below)
class EmailValidatorto validate email address' validity)Tenant#is_trial?check)Checklist
Please check directly on the box once each of these are done