Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

fix: treate view as physical view instead of pseudo table (#10718)

h3n4l7e1c6555e1f2
diff --git a/backend/plugin/parser/base/span.go b/backend/plugin/parser/base/span.go
index bf794152d8..69cc58419d 100644
--- a/backend/plugin/parser/base/span.go
+++ b/backend/plugin/parser/base/span.go
@@ -115,6 +115,43 @@ func (p *PseudoTable) GetQuerySpanResult() []QuerySpanResult {
return p.Columns
}
+// PhysicalView is the resource of a physical view, which can be refer with schema name,
+// and its columns can refer to the columns of the underlying tables.
+type PhysicalView struct {
+ baseTableSource
+
+ // Server is the normalized server name, it's empty if the column comes from the connected server.
+ Server string
+ // Database is the normalized database name, it should not be empty.
+ Database string
+ // Schema is the normalized schema name, it should not be empty for the engines that support schema, and should be empty for the engines that don't support schema.
+ Schema string
+ // Name is the normalized table name, it should not be empty.
+ Name string
+ // Columns are the columns of the table.
+ Columns []QuerySpanResult
+}
+
+func (p *PhysicalView) GetTableName() string {
+ return p.Name
+}
+
+func (p *PhysicalView) GetSchemaName() string {
+ return p.Schema
+}
+
+func (p *PhysicalView) GetDatabaseName() string {
+ return p.Database
+}
+
+func (p *PhysicalView) GetServerName() string {
+ return p.Server
+}
+
+func (p *PhysicalView) GetQuerySpanResult() []QuerySpanResult {
+ return p.Columns
+}
+
// PhysicalTable is the resource of a physical table.
type PhysicalTable struct {
baseTableSource
diff --git a/backend/plugin/parser/pg/query_span_extractor.go b/backend/plugin/parser/pg/query_span_extractor.go
index d622b8f20a..206f2158c2 100644
--- a/backend/plugin/parser/pg/query_span_extractor.go
+++ b/backend/plugin/parser/pg/query_span_extractor.go
@@ -933,9 +933,12 @@ func (q *querySpanExtractor) findTableSchema(schemaName string, tableName string
if err != nil {
return nil, err
}
- return &base.PseudoTable{
- Name: tableName,
- Columns: columns,
+ return &base.PhysicalView{
+ Server: "",
+ Database: q.connectedDB,
+ Schema: schemaName,
+ Name: tableName,
+ Columns: columns,
}, nil
}
@@ -944,9 +947,12 @@ func (q *querySpanExtractor) findTableSchema(schemaName string, tableName string
if err != nil {
return nil, err
}
- return &base.PseudoTable{
- Name: tableName,
- Columns: columns,
+ return &base.PhysicalView{
+ Server: "",
+ Database: q.connectedDB,
+ Schema: schemaName,
+ Name: tableName,
+ Columns: columns,
}, nil
}
return nil, nil
diff --git a/backend/plugin/parser/tidb/query_span_extractor.go b/backend/plugin/parser/tidb/query_span_extractor.go
index 0a7fb2d1bf..4f00869d73 100644
--- a/backend/plugin/parser/tidb/query_span_extractor.go
+++ b/backend/plugin/parser/tidb/query_span_extractor.go
@@ -779,9 +779,10 @@ func (q *querySpanExtractor) findTableSchema(databaseName string, tableName stri
if err != nil {
return nil, err
}
- return &base.PseudoTable{
- Name: view,
- Columns: columns,
+ return &base.PhysicalView{
+ Database: databaseName,
+ Name: view,
+ Columns: columns,
}, nil
}
}