Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Function to add synonyms for tables and columns #89

Open
aakashb14 opened this issue Aug 19, 2024 · 3 comments
Open

Function to add synonyms for tables and columns #89

aakashb14 opened this issue Aug 19, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@aakashb14
Copy link

What are you trying to achieve?
We are trying to add synonyms for tables and columns in our direct lake model using a lakehouse table which has the synonyms as a comma separated list. Right now, synonyms must be added manually which is very time consuming for a model with 100+ tables and 1000+ columns. We want to exploit Copilot and Q&A features and need to enter synonyms programmatically.

What have you tried so far?
We tried various options to see if the "synonyms" property that appears in tabular editor can be accessed via sempy labs so the synonyms in lakehouse table can be directly applied but haven't been able to find any function that exposes this property.

Is there a way to do this using sempy labs?

@aakashb14 aakashb14 added the question Further information is requested label Aug 19, 2024
@m-kovalsky
Copy link
Collaborator

Currently, there is no documented schema for this in TOM. It's just a big section of json. I've parsed through it to get a list of they table, column, measure & hierarchy synonyms and am looking into adding synonyms. It would be a function like this (one for tables, one for columns, one for measures etc.).

def add_table_synonym(dataset: str, culture_name: str, table_name: str, synonym_name: str, weight: Optional[Decimal] = None, workspace: Optional[str] = None):

@aakashb14
Copy link
Author

Thank you! I managed to write a code to parse out the json and update the synonyms. One error I ran into is if the "Content" property is not set to the base JSON code in tabular editor, I get an error message. I've noted the error and the base JSON code below.

Error msg: AttributeError: 'NoneType' object has no attribute 'Content'

Base JSON code: {"Version":"1.2.0","Language":"en-US","DynamicImprovement":"None","Entities":{}}

I'm using LinguisticMetadata.Content property within Cultures in TOM to update the json and it works only when JSON is set to the base JSON code.

Any idea how this error can be fixed using code rather than manual intervention?

@m-kovalsky
Copy link
Collaborator

If you have a culture with no 'base JSON code' it is a problem. Creating the 'Content' as json code gives an error. It does accept XML code but then it stays as XML and doesn't auto-convert to json so it is problematic. Need to sort out how to populate the Content if the base JSON code isn't there.

@m-kovalsky m-kovalsky added enhancement New feature or request and removed question Further information is requested labels Aug 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants