[ 
https://issues.apache.org/jira/browse/KYLIN-4325?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Zhong Yanghong updated KYLIN-4325:
----------------------------------
    Description: 
For decimal field, the following logic in *SelfDefineSortableKey* is not 
correct:
{code}
public void init(Text key, byte typeId) {
        this.typeId = typeId;
        this.rawKey = key;
        if (isNumberFamily()) {
            String valueStr = new String(key.getBytes(), 1, key.getLength() - 
1, StandardCharsets.UTF_8);
            if (isIntegerFamily()) {
                this.keyInObj = Long.parseLong(valueStr);
            } else {
                this.keyInObj = Double.parseDouble(valueStr);
            }
        } else {
            this.keyInObj = key;
        }
    }
{code}
Since the result of Double.valueOf("206779569545636097").toString() == 
"206779569545636097" is false.

When encoding decimal fields, it's better to regard it as a string rather than 
a number.

What's more, when building global dictionary, even for other numeric field, we 
should regard it as string rather than number

  was:
For decimal field, the following logic in *SelfDefineSortableKey* is not 
correct:
{code}
public void init(Text key, byte typeId) {
        this.typeId = typeId;
        this.rawKey = key;
        if (isNumberFamily()) {
            String valueStr = new String(key.getBytes(), 1, key.getLength() - 
1, StandardCharsets.UTF_8);
            if (isIntegerFamily()) {
                this.keyInObj = Long.parseLong(valueStr);
            } else {
                this.keyInObj = Double.parseDouble(valueStr);
            }
        } else {
            this.keyInObj = key;
        }
    }
{code}
Since the result of Double.valueOf("206779569545636097").toString() == 
"206779569545636097" is false.

When encoding decimal fields, it's better to regard it as a string rather than 
a number.


> ”Value not exists“ when invoke getIdFromValue() for decimal field during cube 
> building
> --------------------------------------------------------------------------------------
>
>                 Key: KYLIN-4325
>                 URL: https://issues.apache.org/jira/browse/KYLIN-4325
>             Project: Kylin
>          Issue Type: Improvement
>          Components: Job Engine
>            Reporter: Zhong Yanghong
>            Assignee: Zhong Yanghong
>            Priority: Major
>
> For decimal field, the following logic in *SelfDefineSortableKey* is not 
> correct:
> {code}
> public void init(Text key, byte typeId) {
>         this.typeId = typeId;
>         this.rawKey = key;
>         if (isNumberFamily()) {
>             String valueStr = new String(key.getBytes(), 1, key.getLength() - 
> 1, StandardCharsets.UTF_8);
>             if (isIntegerFamily()) {
>                 this.keyInObj = Long.parseLong(valueStr);
>             } else {
>                 this.keyInObj = Double.parseDouble(valueStr);
>             }
>         } else {
>             this.keyInObj = key;
>         }
>     }
> {code}
> Since the result of Double.valueOf("206779569545636097").toString() == 
> "206779569545636097" is false.
> When encoding decimal fields, it's better to regard it as a string rather 
> than a number.
> What's more, when building global dictionary, even for other numeric field, 
> we should regard it as string rather than number



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to