Skip to content

Commit f82e244

Browse files
committed
Updated query store
1 parent d0bd96d commit f82e244

File tree

5 files changed

+23
-15
lines changed

5 files changed

+23
-15
lines changed

deploy_ai_search/text_2_sql_query_cache.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def get_index_fields(self) -> list[SearchableField]:
5353
vector_search_profile_name=self.vector_search_profile_name,
5454
),
5555
SearchableField(
56-
name="Query", type=SearchFieldDataType.String, filterable=True
56+
name="SQLQuery", type=SearchFieldDataType.String, filterable=True
5757
),
5858
ComplexField(
5959
name="Schemas",
@@ -69,13 +69,13 @@ def get_index_fields(self) -> list[SearchableField]:
6969
collection=True,
7070
fields=[
7171
SearchableField(
72-
name="Name", type=SearchFieldDataType.String
72+
name="ColumnName", type=SearchFieldDataType.String
7373
),
7474
SearchableField(
75-
name="Definition", type=SearchFieldDataType.String
75+
name="ColumnDefinition", type=SearchFieldDataType.String
7676
),
7777
SearchableField(
78-
name="Type", type=SearchFieldDataType.String
78+
name="DataType", type=SearchFieldDataType.String
7979
),
8080
SearchableField(
8181
name="AllowedValues",

deploy_ai_search/text_2_sql_schema_store.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def get_index_fields(self) -> list[SearchableField]:
8888
name="Columns",
8989
collection=True,
9090
fields=[
91-
SearchableField(name="ColumnName", type=SearchFieldDataType.String),
91+
SearchableField(name="Name", type=SearchFieldDataType.String),
9292
SearchableField(name="Definition", type=SearchFieldDataType.String),
9393
SearchableField(name="DataType", type=SearchFieldDataType.String),
9494
SearchableField(
@@ -125,7 +125,7 @@ def get_index_fields(self) -> list[SearchableField]:
125125
# This is needed to enable semantic searching against the column names as complex field types are not used.
126126
),
127127
ComplexField(
128-
name="ImmediateRelationships",
128+
name="ImmediateEntityRelationships",
129129
collection=True,
130130
fields=[
131131
SearchableField(
@@ -150,6 +150,11 @@ def get_index_fields(self) -> list[SearchableField]:
150150
),
151151
],
152152
),
153+
SimpleField(
154+
name="CompleteEntityRelationships",
155+
type=SearchFieldDataType.String,
156+
collection=True,
157+
),
153158
SimpleField(
154159
name="DateLastModified",
155160
type=SearchFieldDataType.DateTimeOffset,

text_2_sql/data_dictionary/data_dictionary_creator.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class ColumnItem(BaseModel):
2222
"""A class to represent a column item."""
2323

2424
name: str = Field(..., alias="Name")
25-
type: str = Field(..., alias="Type")
25+
data_type: str = Field(..., alias="DataType")
2626
definition: Optional[str] = Field(..., alias="Definition")
2727
distinct_values: Optional[list[any]] = Field(
2828
None, alias="DistinctValues", exclude=True
@@ -37,15 +37,17 @@ def from_sql_row(cls, row, columns):
3737
"""A method to create a ColumnItem from a SQL row."""
3838
result = dict(zip(columns, row))
3939
return cls(
40-
name=result["Name"], type=result["Type"], definition=result["Definition"]
40+
name=result["Name"],
41+
type=result["DataType"],
42+
definition=result["Definition"],
4143
)
4244

4345

4446
class EntityItem(BaseModel):
4547
"""A class to represent an entity item."""
4648

4749
entity: str = Field(..., alias="Entity")
48-
description: Optional[str] = Field(..., alias="Description")
50+
definition: Optional[str] = Field(..., alias="Definition")
4951
name: str = Field(..., alias="Name", exclude=True)
5052
entity_schema: str = Field(..., alias="Schema", exclude=True)
5153
entity_name: Optional[str] = Field(default=None, alias="EntityName")
@@ -67,7 +69,7 @@ def from_sql_row(cls, row, columns):
6769
entity=entity,
6870
name=result["Entity"],
6971
entity_schema=result["EntitySchema"],
70-
description=result["Description"],
72+
definition=result["Definition"],
7173
)
7274

7375

@@ -102,20 +104,20 @@ def __init__(
102104
def extract_table_entities_sql_query(self) -> str:
103105
"""An abstract property to extract table entities from a database.
104106
105-
Must return 3 columns: Entity, EntitySchema, Description."""
107+
Must return 3 columns: Entity, EntitySchema, Definition."""
106108

107109
@property
108110
@abstractmethod
109111
def extract_view_entities_sql_query(self) -> str:
110112
"""An abstract property to extract view entities from a database.
111113
112-
Must return 3 columns: Entity, EntitySchema, Description."""
114+
Must return 3 columns: Entity, EntitySchema, Definition."""
113115

114116
@abstractmethod
115117
def extract_columns_sql_query(self, entity: EntityItem) -> str:
116118
"""An abstract method to extract column information from a database.
117119
118-
Must return 3 columns: Name, Type, Definition."""
120+
Must return 3 columns: Name, DataType, Definition."""
119121

120122
def extract_distinct_values_sql_query(
121123
self, entity: EntityItem, column: ColumnItem

text_2_sql/data_dictionary/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ azure-identity
33
python-dotenv
44
pydantic
55
openai
6+
networkx

text_2_sql/data_dictionary/sql_sever_data_dictionary_creator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def extract_view_entities_sql_query(self) -> str:
5252
return """SELECT
5353
v.TABLE_NAME AS Entity,
5454
v.TABLE_SCHEMA AS EntitySchema,
55-
CAST(ep.value AS NVARCHAR(500)) AS Description
55+
CAST(ep.value AS NVARCHAR(500)) AS Definition
5656
FROM
5757
INFORMATION_SCHEMA.VIEWS v
5858
LEFT JOIN
@@ -66,7 +66,7 @@ def extract_columns_sql_query(self, entity: EntityItem) -> str:
6666
"""A property to extract column information from a SQL Server database."""
6767
return f"""SELECT
6868
c.COLUMN_NAME AS Name,
69-
c.DATA_TYPE AS Type,
69+
c.DATA_TYPE AS DataType,
7070
CAST(ep.value AS NVARCHAR(500)) AS Definition
7171
FROM
7272
INFORMATION_SCHEMA.COLUMNS c

0 commit comments

Comments
 (0)