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

feat: add Microsoft SQL Server Offline store. #1136

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

error9098x
Copy link

@error9098x error9098x commented Oct 31, 2023

Description

This PR adds Microsoft SQL Server as an Offline Store.
I have tried my best to add all functionalities from the Postgres & MySQL Offline Store.
I have used the MSSQL equivalent of Materialized Views which is Indexed Views. I made sure no function is vulnerable to SQL Injection. I didn't add any extra features in this PR, it's mostly the implementation of all the methods to satisfy the interface definition.

Type of change

Feature: Implemented Microsoft SQL Server as an Offline Store

Does this correspond to an open issue?

Closes: #1117

Select type(s) of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update

Checklist:

  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have fixed any merge conflicts

@error9098x
Copy link
Author

@sdreyer can you have a look into this ?

Copy link
Contributor

@ahmadnazeri ahmadnazeri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @error9098x for the PR! I have left you some comments. You have most of the backend but will need to add a Microsoft SQL Server in order for us to test it. Also, you will need to expose registering a Microsoft SQL to the user by adding the client side of things as well. Let me know if you have any questions.

query = fmt.Sprintf("CREATE VIEW %s AS SELECT %s as entity, %s as value, CONVERT(datetimeOffset, '%s', 120) as ts FROM %s",
sanitize(tableName), sanitize(schema.Entity), sanitize(schema.Value), time.Now().UTC().Format("2006-01-02 15:04:05"), sanitize(schema.SourceTable))
}
fmt.Printf("Resource creation query: %s", query)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we remove this print statement?

return q.trainingSetQuery(store, def, tableName, labelName, true)
}

func (q MSSQLQueries) trainingSetQuery(store *sqlOfflineStore, def TrainingSetDef, tableName string, labelName string, isUpdate bool) error {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The training set query will need to support lag features as well. Here is an example of lag features for other sql providers.

}

func (q MSSQLQueries) numRows(n interface{}) (int64, error) {
return n.(int64), nil
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

converting this into

numRows, ok := n.(int64)

would be safer in order to avoid panic.

}

func (ms MSSQLConfig) MutableFields() ss.StringSet {
return ss.StringSet{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does it make sense to have everything mutable? It would be essentially a different provider if they change everything.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it makes sense to have the Username and Password be mutable only.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Provider Request]: Implement Microsoft SQL Server as an Offline Store
2 participants