USQL使用用户定义的数据类型列创建用户定义的表类型

时间:2018-05-08 14:45:46

标签: azure-data-lake u-sql

我将用户定义的类型定义为

/* 
code snippet will Wait 30 seconds for 
an element to be present on the page and check for its 
presence once every 5 seconds.
*/
Wait wait = new FluentWait(driver)
    .withTimeout(30, SECONDS)
    .pollingEvery(5, SECONDS)
    .ignoring(NoSuchElementException.class);

WebElement foo = wait.until(new Function() {
    public WebElement apply(WebDriver driver) {
        return driver.findElement(By.id("foo"));
    }
});

我想定义一个返回数据类型

的表值函数
namespace AddOns{
[SqlUserDefinedType(typeof(JsonObjectFormatter))]
    public class JsonObject
    {
        public string Value {get;set;}
        ... // this is just a dummy representation 
    }
}

但是我收到错误

REFERENCE ASSEMBLY [AddOns];

CREATE TYPE Insight.dbo.JsonRow
AS TABLE
(
        [Id] Guid,
        [Value] AddOns.JsonObject
);

我已在ADLA的本地实例中注册了相应的DLL,并且当我将数据持久保存到文件时,我能够访问过程'E_CSC_USER_INVALIDCOLUMNTYPE: 'AddOns.JsonObject' cannot be used as column type. Description: The column type must be a supported scalar, complex or user defined type. Resolution: Ensure the column type is a supported type. For a user defined type, make sure the type is registered, the type name is fully qualified, and the required assembly is referenced by the script.' *** Compile failed ! 语句中的类型。但不能将其作为TVF返回类型返回

1 个答案:

答案 0 :(得分:0)

创建自定义类型时,仅限于内置类型。来自str.count(): Return the number of (non-overlapping) occurrences of substring sub in string s(我粘贴的文字最后一行仅表示内置类型):

U-SQL可以使用CREATE TYPE语句命名和注册表类型。

Create_Type_Statement :=                                                                                 
    'CREATE' 'TYPE' ['IF' 'NOT' 'EXISTS'] Type_Identifier   
    'AS' Anonymous_Table_Type.
Type_Identifier := 
    DB_Object_Identifier.

Anonymous_Table_Type :=  
    'TABLE' '(' Column_Definition_List ')'.

语法元素的语义

...

Column_Definition_List

定义表架构,如下所示:

Column_Definition_List :=                                                                           
     Column_Definition { ',' Column_Definition }.

Column_Definition

列定义的格式为

Column_Definition :=    
    Quoted_or_Unquoted_Identifier Built_in_Type.