从数据库中选择时间戳记时,WSO2 DSS问题 [英] WSO2 DSS issue when selecting Timestamps from Database

查看:55
本文介绍了从数据库中选择时间戳记时,WSO2 DSS问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在定义查询以从WSO2 DSS中的Cassandra中获取一些数据时遇到了问题.查询(和操作)本身正在工作,但是我的问题是当我尝试获取时间戳记时.我只得到缺少时间部分的日期和时区(2017-01-11 + 0100).我猜想这与到无法正常工作的dateTime xsdType的映射有关.您是否已经遇到过这个问题,并且您有解决方案来获取时间戳吗?

I've an issue defining a query to get some data out of Cassandra in WSO2 DSS. The query (and the operation) itself is working but my problem is when I try to get a timestamp as a result. I only get the date and the timezone (2017-01-11+0100) the time part is missing. I guess that this is somehow related on the mapping to dateTime xsdType that is not working correctly. Did you already face this issue, and do you have a solution to get the timestamp?

这是一个查询示例

<query id="getDataQuery" useConfig="CassandraDB">
    <expression>SELECT ts,value FROM keyspace.ts_tp WHERE name = :name</expression>
    <result element="result" rowName="data">
        <element column="ts" name="ts" xsdType="dateTime"/>
        <element column="value" name="value" xsdType="decimal"/>
    </result>
    <param name="name" paramType="SCALAR" sqlType="STRING"/>
</query>

谢谢

推荐答案

似乎是dss dateTime映射中的一个问题,我打开了

Seems to be an issue in dss dateTime mapping, I opened a Jira ticket @wso2 to be sure. In order to make my call return the right values I made the following (Warning painful solution :))

查询现在返回以ms为单位的unix时间戳

The query returns now the unix Timestamp in ms

<query id="getDataQuery" useConfig="CassandraDB">
    <expression>SELECT unixTimestampOf(minTimeuuid(ts)) as dt,value FROM keyspace.ts_tp WHERE source = :source and name = :name and bucket = :bucket and ts &gt;= :tsFrom and ts &lt;= :tsTo</expression>
    <result element="result" rowName="data">
        <element column="dt" name="ts" xsdType="int"/>
        <element column="value" name="value" xsdType="decimal"/>
    </result>
    <param name="source" paramType="SCALAR" sqlType="STRING"/>
    <param name="name" paramType="SCALAR" sqlType="STRING"/>
    <param name="bucket" paramType="SCALAR" sqlType="INTEGER"/>
    <param name="tsFrom" paramType="SCALAR" sqlType="TIMESTAMP"/>
    <param name="tsTo" paramType="SCALAR" sqlType="TIMESTAMP"/>
</query>

得到结果后,我将应用XSL转换来计算日期

Once I get the result I apply an XSL transformation to compute the dates

<xsl:stylesheet exclude-result-prefixes="xsl soapenv" version="2.0" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output encoding="utf-8" indent="yes" method="xml" omit-xml-declaration="yes"/>
   <xsl:template match="@*|node()">
      <xsl:copy>
        <xsl:apply-templates select="@*|node()"/>
      </xsl:copy>
   </xsl:template>

    <xsl:template match="dt">
      <xsl:element name="ts">
         <xsl:value-of select='xs:dateTime("1970-01-01T00:00:00") + . * xs:dayTimeDuration("PT0.001S")'/>
      </xsl:element>
    </xsl:template>
</xsl:stylesheet>

它需要在不同的时区进行测试,并且可以节省日光,但是它似乎是一种有效的工具,正在等待正式的修复.

It needs to be tested with different time zones, and day light savings but it seems to be a working hack, waiting for the official fix.

这篇关于从数据库中选择时间戳记时,WSO2 DSS问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆