MSSQL to Snowflake Data Type Mapping - sql-server

Does anyone have a data type mapping from MSSQL (Azure MSSQL) to Snowflake?
This is the current mapping I have:
# Key: MSSQL, value: Snowflake
DATA_TYPE_MAPPING = {
"BIGINT": "BIGINT",
"BINARY": "BLOB",
"BIT": "BOOLEAN",
"DATE": "DATE",
"DATETIME": "DATETIME",
"DATETIME2": "DATETIME",
"DOUBLE": "DOUBLE",
"DECIMAL": "DECIMAL",
"FLOAT": "FLOAT",
"ENUM": "STRING",
"SET": "STRING",
"IMAGE": "BINARY",
"INT": "INT",
"INTEGER": "INTEGER",
"LONGTEXT": "VARCHAR",
"MEDIUMINT": "INTEGER",
"MEDIUMTEXT": "VARCHAR",
"NUMERIC": "NUMBER",
"REAL": "FLOAT4",
"SMALLINT": "SMALLINT",
"TEXT": "VARCHAR",
"TIME": "TIME",
"TIMESTAMP": "TIMESTAMP",
"TINYTEXT": "STRING",
"TINYINT": "TINYINT",
"VARCHAR": "VARCHAR",
"VARBINARY": "VARBINARY",
}
I could not find a complete mapping. If someone knows about one, please let us know.

The data type mapping is described in Microsoft SQL Server to Snowflake Migration Reference Manual
Appendix A: MICROSOFT SQL SERVER
TO SNOWFLAKE FEATURE MAPPING
Subsection: Data Types

After looking at the manual Microsoft SQL Server to Snowflake Migration Reference Manual mentioned in this post I have changed the initial mapping to:
MSSQL_SNOWFLAKE_DATA_TYPE_MAPPING = {
"BIGINT": "NUMBER",
"BINARY": "BINARY",
"BIT": "BOOLEAN",
"CHAR": "VARCHAR(1)",
"DATE": "DATE",
"DATETIME": "DATETIME",
"DATETIME2": "TIMESTAMP_NTZ",
"DATETIMEOFFSET": "TIMESTAMP_LTZ",
"DOUBLE": "DOUBLE",
"DECIMAL": "NUMBER",
"FLOAT": "FLOAT",
"ENUM": "STRING",
"SET": "STRING",
"IMAGE": "BINARY",
"INT": "NUMBER",
"INTEGER": "INTEGER",
"LONGTEXT": "VARCHAR",
"MEDIUMINT": "INTEGER",
"MEDIUMTEXT": "VARCHAR",
"MONEY": "NUMBER",
"NCHAR": "VARCHAR",
"NVARCHAR": "VARCHAR",
"NTEXT": "VARCHAR",
"NUMERIC": "NUMBER",
"REAL": "FLOAT",
"SMALLDATETIME": "DATETIME",
"SMALLINT": "NUMBER",
"SMALLMONEY": "NUMBER",
"TEXT": "VARCHAR",
"TIME": "TIME",
"TIMESTAMP": "TIMESTAMP_NTZ",
"TINYTEXT": "STRING",
"TINYINT": "NUMBER",
"VARCHAR": "VARCHAR",
"VARBINARY": "BINARY",
}

Related

List user properties from Microsoft Graph API

We are making integrations to Azure AD for various companies. As a part of this work we have to ask which fields in their systems needs to be mapped over to our system.
Because people don't actually use the system names day to day, most people we encounter have no clue of this.
Given correct credentials, is it possible to either fetch all properties that a User object can return or is there a predefined list already?
The closest I could find have been this one, but the url says "previous version", so I'm not sure if it's been changed or not.
I tried finding it via the API using $select=*, but as you may know that will just give the default list of properties.
The available properties are documented in the user resource section of the Graph documentation. The JSON prototype for the user looks like this:
{
"aboutMe": "string",
"accountEnabled": true,
"ageGroup": "string",
"assignedLicenses": [{"#odata.type": "microsoft.graph.assignedLicense"}],
"assignedPlans": [{"#odata.type": "microsoft.graph.assignedPlan"}],
"birthday": "String (timestamp)",
"businessPhones": ["string"],
"city": "string",
"companyName": "string",
"consentProvidedForMinor": "string",
"country": "string",
"department": "string",
"displayName": "string",
"employeeId": "string",
"faxNumber" : "string",
"givenName": "string",
"hireDate": "String (timestamp)",
"id": "string (identifier)",
"imAddresses": ["string"],
"interests": ["string"],
"jobTitle": "string",
"legalAgeGroupClassification": "string",
"licenseAssignmentStates": [{"#odata.type": "microsoft.graph.licenseAssignmentState"}],
"mail": "string",
"mailboxSettings": {"#odata.type": "microsoft.graph.mailboxSettings"},
"mailNickname": "string",
"mobilePhone": "string",
"mySite": "string",
"officeLocation": "string",
"onPremisesDistinguishedName": "string",
"onPremisesDomainName": "string",
"onPremisesExtensionAttributes": {"#odata.type": "microsoft.graph.onPremisesExtensionAttributes"},
"onPremisesImmutableId": "string",
"onPremisesLastSyncDateTime": "String (timestamp)",
"onPremisesProvisioningErrors": [{"#odata.type": "microsoft.graph.onPremisesProvisioningError"}],
"onPremisesSamAccountName": "string",
"onPremisesSecurityIdentifier": "string",
"onPremisesSyncEnabled": true,
"onPremisesUserPrincipalName": "string",
"otherMails": "string",
"passwordPolicies": "string",
"passwordProfile": {"#odata.type": "microsoft.graph.passwordProfile"},
"pastProjects": ["string"],
"postalCode": "string",
"preferredDataLocation": "string",
"preferredLanguage": "string",
"preferredName": "string",
"provisionedPlans": [{"#odata.type": "microsoft.graph.provisionedPlan"}],
"proxyAddresses": ["string"],
"responsibilities": ["string"],
"schools": ["string"],
"showInAddressList": true,
"skills": ["string"],
"state": "string",
"streetAddress": "string",
"surname": "string",
"usageLocation": "string",
"userPrincipalName": "string",
"userType": "string",
"calendar": { "#odata.type": "microsoft.graph.calendar" },
"calendarGroups": [{ "#odata.type": "microsoft.graph.calendarGroup" }],
"calendarView": [{ "#odata.type": "microsoft.graph.event" }],
"calendars": [ {"#odata.type": "microsoft.graph.calendar"} ],
"contacts": [ { "#odata.type": "microsoft.graph.contact" } ],
"contactFolders": [ { "#odata.type": "microsoft.graph.contactFolder" } ],
"createdObjects": [ { "#odata.type": "microsoft.graph.directoryObject" } ],
"directReports": [ { "#odata.type": "microsoft.graph.directoryObject" } ],
"drive": { "#odata.type": "microsoft.graph.drive" },
"drives": [ { "#odata.type": "microsoft.graph.drive" } ],
"events": [ { "#odata.type": "microsoft.graph.event" } ],
"inferenceClassification": { "#odata.type": "microsoft.graph.inferenceClassification" },
"mailFolders": [ { "#odata.type": "microsoft.graph.mailFolder" } ],
"manager": { "#odata.type": "microsoft.graph.directoryObject" },
"memberOf": [ { "#odata.type": "microsoft.graph.directoryObject" } ],
"messages": [ { "#odata.type": "microsoft.graph.message" } ],
"outlook": { "#odata.type": "microsoft.graph.outlookUser" },
"ownedDevices": [ { "#odata.type": "microsoft.graph.directoryObject" } ],
"ownedObjects": [ { "#odata.type": "microsoft.graph.directoryObject" } ],
"photo": { "#odata.type": "microsoft.graph.profilePhoto" },
"registeredDevices": [ { "#odata.type": "microsoft.graph.directoryObject" } ]
}
In order to return a specific set of properties, you need to list each of them in your $select statement. You cannot use a wildcard (*) to retrieve the entire set. The simpliest method is to start with the default $select and add the aditional properties you're looking for:
$select=businessPhones,displayName,givenName,jobTitle,mail,mobilePhone,officeLocation,preferredLanguage,surname,userPrincipalName,id

I created Analysis services databases by xmla scripts. But I can't show the values in table. e.g. run DAX 'evaluate table_name',there presents nothing

I want to create many Analysis Services Databases, but don't want to create Analysis Services Tabular Projects manually. So I run some xmla scripts. The databases are constructed After running, but I can't show or use the values in the table. when I run the DAX script 'evaluate table_name', there present nothing.
the example xmla scripts:
{
"create": {
"database": {
"name": "SQA_200_12",
"compatibilityLevel": 1200,
"model": {
"culture": "en-US",
"dataSources": [
{
"name": "SqlServer localhost SQATables",
"connectionString": "Provider=SQLNCLI11;Data Source=localhost;Initial Catalog=SQATables;Integrated Security=SSPI;Persist Security Info=false",
"impersonationMode": "impersonateAccount",
"account": "fareast\v-yanze",
"annotations": [
{
"name": "ConnectionEditUISource",
"value": "SqlServer"
}
]
}
],
"tables": [
{
"name": "200_12",
"columns": [
{
"name": "Year",
"dataType": "string",
"sourceColumn": "Year",
"sourceProviderType": "Char"
},
{
"name": "Award",
"dataType": "string",
"sourceColumn": "Award",
"sourceProviderType": "Char"
},
{
"name": "Category",
"dataType": "string",
"sourceColumn": "Category",
"sourceProviderType": "Char"
},
{
"name": "Nominated work",
"dataType": "string",
"sourceColumn": "Nominated work",
"sourceProviderType": "Char"
},
{
"name": "Result",
"dataType": "string",
"sourceColumn": "Result",
"sourceProviderType": "Char"
}
],
"partitions": [
{
"name": "200_12",
"dataView": "full",
"source": {
"query": " SELECT [dbo].[200_12].* FROM [dbo].[200_12] ",
"dataSource": "SqlServer localhost SQATables"
}
}
],
"annotations": [
{
"name": "_TM_ExtProp_QueryDefinition",
"value": " SELECT [dbo].[200_12].* FROM [dbo].[200_12] "
},
{
"name": "_TM_ExtProp_DbTableName",
"value": "200_12"
},
{
"name": "_TM_ExtProp_DbSchemaName",
"value": "dbo"
}
]
}
],
"annotations": [
{
"name": "ClientCompatibilityLevel",
"value": "400"
}
]
}
}
}
}
Or are there any different ways to create analysis services databases conveniently. Thank you.
It looks like you have not processed the model. Right click the name of the model database in SSMS, and select the Process option.

Join 2 arrays by key and value (AngularJS)

I have 2 objects
{
"_id": "58b7f36b3354c24630f6f3b0",
"name": "refcode",
"caption": "Reference",
"type": "string",
"search": false,
"required": false,
"table": true,
"expansion": true
},
and
{
"_id": "58b7f36b3354c24630f6f3c8",
"vacancyid": "0",
"refcode": "THIS IS MY REF",
"position": "Test",
"jobtype": "Temp",
"department": "Industrial",
"branch": "Office",
"startdate": "02/12/2013",
"contactname": "Person Name",
"contactemail": "person#domain",
"Q_V_TYP": "Daily",
"score": 0
},
Object one defines what a field should be and what it is called
The second object is a job description.
What i need is to match a field to each key (this even sounds confusing i my head, so here is an example)
{
"_id": "58b7f36b3354c24630f6f3c8",
"vacancyid": "0",
"refcode": {
"_id": "58b7f36b3354c24630f6f3b0",
"name": "refcode",
"caption": "Reference",
"type": "string",
"search": false,
"required": false,
"table": true,
"expansion": true,
"value": "THIS IS MY REF"
}
},
"position": "Test",
"jobtype": "Temp",
"department": "Industrial",
"branch": "Office",
"startdate": "02/12/2013",
"contactname": "Person Name",
"contactemail": "person#domain",
"Q_V_TYP": "Daily",
"score": 0
},
Here you go:
var def = {
"_id": "58b7f36b3354c24630f6f3b0",
"name": "refcode",
"caption": "Reference",
"type": "string",
"search": false,
"required": false,
"table": true,
"expansion": true
};
var jobDesc = {
"_id": "58b7f36b3354c24630f6f3c8",
"vacancyid": "0",
"refcode": "THIS IS MY REF",
"position": "Test",
"jobtype": "Temp",
"department": "Industrial",
"branch": "Office",
"startdate": "02/12/2013",
"contactname": "Person Name",
"contactemail": "person#domain",
"Q_V_TYP": "Daily",
"score": 0
};
var jobDescKeysArr = Object.keys(jobDesc);
if (jobDescKeysArr.indexOf(def.name) !== -1) {
// A match.
def.value = jobDesc[def.name];
jobDesc[def.name] = Object.assign({}, def);
console.log(jobDesc)
}

Cant Save relational Entities in breezejs

I have two entities created through manager.createEntity(type);.. z-validate wont display validation errors if i try to create them otherwise
..entity orderdetails must have a valid key from order. and later...
... //changed some stuff but never keys
orderdetails.Time = new Date();
orderdetails.order = order; //am i creating the relation right here?
The app will work great offline but when i save changes to the server..
manager.saveChanges([order,orderdetails]);
The sever is returning
...orderdetails","KeyValues":["fd...28"],"PropertyName":"order",ErrorMessage":"The order field is required."
Any idea how i can go through this? i have been reading documentations for days.
Metadata looks like this
{
"schema": {
"namespace": "Inventory.API",
"alias": "Self",
"annotation:UseStrongSpatialTypes": "false",
"xmlns:annotation": "http://schemas.microsoft.com/ado/2009/02/edm/annotation",
"xmlns:customannotation": "http://schemas.microsoft.com/ado/2013/11/edm/customannotation",
"xmlns": "http://schemas.microsoft.com/ado/2009/11/edm",
"cSpaceOSpaceMapping": "[\"Inventory.API.Order\",\"Inventory.API.Entities.Order\"],[\"Inventory.API.OrderDetail\",\"Inventory.API.Entities.OrderDetail\"],[\"Inventory.API.DifferentDetail\",\"Inventory.API.Entities.DifferentDetail\"]",
"entityType": [ {
"name": "Order",
"customannotation:ClrType": "Inventory.API.Entities.Order, Inventory.API, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null",
"key": {
"propertyRef": {
"name": "Id"
}
},
"property": [{
"name": "Id",
"type": "Edm.Guid",
"nullable": "false",
"annotation:StoreGeneratedPattern": "Identity"
}, {
"name": "BarCode",
"type": "Edm.String",
"maxLength": "Max",
"fixedLength": "false",
"unicode": "true"
}, {
"name": "Name",
"type": "Edm.String",
"maxLength": "Max",
"fixedLength": "false",
"unicode": "true"
}, {
"name": "UnitPrice",
"type": "Edm.Decimal",
"precision": "18",
"scale": "2",
"nullable": "false"
}, {
"name": "Count",
"type": "Edm.Decimal",
"precision": "18",
"scale": "2",
"nullable": "false"
}],
"navigationProperty": [{
"name": "OrderDetails",
"relationship": "Self.OrderDetail_Order",
"fromRole": "OrderDetail_Order_Target",
"toRole": "OrderDetail_Order_Source"
}, {
"name": "DifferentDetails",
"relationship": "Self.DifferentDetail_Order",
"fromRole": "DifferentDetail_Order_Target",
"toRole": "DifferentDetail_Order_Source"
}]
}, {
"name": "OrderDetail",
"customannotation:ClrType": "Inventory.API.Entities.OrderDetail, Inventory.API, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null",
"key": {
"propertyRef": {
"name": "Id"
}
},
"property": [{
"name": "Id",
"type": "Edm.Guid",
"nullable": "false",
"annotation:StoreGeneratedPattern": "Identity"
}, {
"name": "Time",
"type": "Edm.DateTime",
"nullable": "false"
}, {
"name": "UnitPrice",
"type": "Edm.Decimal",
"precision": "18",
"scale": "2",
"nullable": "false"
}, {
"name": "Count",
"type": "Edm.Decimal",
"precision": "18",
"scale": "2",
"nullable": "false"
}, {
"name": "TotalPrice",
"type": "Edm.Decimal",
"precision": "18",
"scale": "2",
"nullable": "false"
}],
"navigationProperty": {
"name": "Order",
"relationship": "Self.OrderDetail_Order",
"fromRole": "OrderDetail_Order_Source",
"toRole": "OrderDetail_Order_Target"
}
}, {
"name": "DifferentDetail",
"customannotation:ClrType": "Inventory.API.Entities.DifferentDetail, Inventory.API, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null",
"key": {
"propertyRef": {
"name": "Id"
}
},
"property": [{
"name": "Id",
"type": "Edm.Guid",
"nullable": "false",
"annotation:StoreGeneratedPattern": "Identity"
}, {
"name": "Time",
"type": "Edm.DateTime",
"nullable": "false"
}, {
"name": "UnitPrice",
"type": "Edm.Decimal",
"precision": "18",
"scale": "2",
"nullable": "false"
}, {
"name": "Count",
"type": "Edm.Decimal",
"precision": "18",
"scale": "2",
"nullable": "false"
}, {
"name": "TotalPrice",
"type": "Edm.Decimal",
"precision": "18",
"scale": "2",
"nullable": "false"
}],
"navigationProperty": {
"name": "Order",
"relationship": "Self.DifferentDetail_Order",
"fromRole": "DifferentDetail_Order_Source",
"toRole": "DifferentDetail_Order_Target"
}
}],
"entityContainer": {
"name": "InventoryContext",
"customannotation:UseClrTypes": "true",
"entitySet": [{
"name": "Orders",
"entityType": "Self.Order"
}, {
"name": "OrderDetails",
"entityType": "Self.OrderDetail"
}, {
"name": "DifferentDetails",
"entityType": "Self.DifferentDetail"
}],
"associationSet": [{
"name": "OrderDetail_Order",
"association": "Self.OrderDetail_Order",
"end": [{
"role": "OrderDetail_Order_Source",
"entitySet": "OrderDetails"
}, {
"role": "OrderDetail_Order_Target",
"entitySet": "Orders"
}]
}, {
"name": "DifferentDetail_Order",
"association": "Self.DifferentDetail_Order",
"end": [{
"role": "DifferentDetail_Order_Source",
"entitySet": "DifferentDetails"
}, {
"role": "DifferentDetail_Order_Target",
"entitySet": "Orders"
}]
}
}
}
You need to map the orderId foreign key property of the OrderDetail and DifferentDetail entities. When Breeze sends the entities to the server, it communicates the relationship between entities using the foreign keys.
I needed to map the orderId foreign key property of the OrderDetail and DifferentDetail entities. When Breeze sends the entities to the server, it communicates the relationship between entities using the foreign keys.
... The relation was there but breeze wont see it as it was defined like this
[Required]
public Order Order { get; set; }
And therefore I changed it to this
[Required]
public Guid Order_Id { get; set; }
[ForeignKey("Order_Id")]
public virtual Order Order{get; set;}
in the DBContext POCO classes then created a new copy of Metadata.

How to define the min size of array in the json schema

I want to make a schema of json file.It's for an array of products.
The json schema is similar as below:
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "Product set",
"type": "array",
"items": {
"title": "Product",
"type": "object",
"properties": {
"id": {
"description": "The unique identifier for a product",
"type": "number"
},
"name": {
"type": "string"
},
"price": {
"type": "number",
"minimum": 0,
"exclusiveMinimum": true
},
"tags": {
"type": "array",
"items": {
"type": "string"
},
"minItems": 1,
"uniqueItems": true
},
"dimensions": {
"type": "object",
"properties": {
"length": {"type": "number"},
"width": {"type": "number"},
"height": {"type": "number"}
},
"required": ["length", "width", "height"]
},
"warehouseLocation": {
"description": "Coordinates of the warehouse with the product",
"$ref": "http://json-schema.org/geo"
}
},
"required": ["id", "name", "price"]
}
}
The array should at least one item in it. How can I define the minimum of the array?
Do I need to add the minimun defination?
To set the minimum # of item in an array, use the "minItems".
See:
https://datatracker.ietf.org/doc/html/draft-fge-json-schema-validation-00#section-5.3.3
and
http://jsonary.com/documentation/json-schema/?section=keywords/Array%20validation
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "Product",
"description": "A product from Acme's catalog",
"type": "object",
"properties": {
...
"tags": {
"type": "array",
"items": {
"type": "string"
},
"minItems": 1,
"maxItems": 4,
"uniqueItems": true
}
},
"required": ["id", "name", "price"]
}
It looks like draft v4 permits what you are looking for. From http://json-schema.org/example1.html:
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "Product",
"description": "A product from Acme's catalog",
"type": "object",
"properties": {
...
"tags": {
"type": "array",
"items": {
"type": "string"
},
"minItems": 1,
"uniqueItems": true
}
},
"required": ["id", "name", "price"]
}
Notice that the "tags" property is defined as an array, with a minimum number of items (1).
I suppose no, at least looking to working draft the minimum is applied only for numeric values, not arrays.
5.1. Validation keywords for numeric instances (number and integer)
...
5.1.3. minimum and exclusiveMinimum
So you should be good with min/maxItems for arrays.

Resources