Skip to content

Subquery union all with all constants order error #666

@sunsun314

Description

@sunsun314
  • dble version: master
  • preconditions :
    Order is error when subQuery with union and one of the union sql all are constants
  • configs:

schema.xml

<?xml version="1.0"?>
<!DOCTYPE dble:schema SYSTEM "schema.dtd">
<dble:schema xmlns:dble="http://dble.cloud/">

    <schema name="TESTDB" dataNode = 'dn1'>
        <!-- auto sharding by id (long) -->
        <table name="BAMS_FLOW_LOG" dataNode="dn1,dn2" rule="sharding-by-hash2"/>
        <table name="travelrecord" dataNode="dn1,dn2" rule="sharding-by-hash2"/>
        <table name="date_table" dataNode="dn1,dn2,dn3" rule="sharding-by-date"/>  
        <!-- global table is auto cloned to all defined data nodes ,so can join
            with any table whose sharding node is in the same data node -->
        <table name="company" primaryKey="ID" type="global" dataNode="dn1,dn2,dn3,dn4"/>
        <table name="goods" primaryKey="ID" type="global" dataNode="dn1,dn2"/>
        <!-- random sharding using mod sharind rule -->
        <table name="hotnews" primaryKey="ID" autoIncrement="true" dataNode="dn1,dn2,dn3,dn4"
               rule="sharding-by-mod"/>
        <table name="customer" primaryKey="ID" dataNode="dn1,dn2"
               rule="sharding-by-mod">
            <childTable name="orders" primaryKey="ID" joinKey="customer_id"
                        parentKey="id">
                <childTable name="order_items" joinKey="order_id"
                            parentKey="id"/>
            </childTable>
            <childTable name="customer_addr" primaryKey="ID" joinKey="customer_id"
                        parentKey="id"/>
        </table>
    </schema>
    
     <schema name="xxxx" dataNode = 'dn1'> </schema>
    
    <!-- <dataNode name="dn1$0-743" dataHost="localhost1" database="db$0-743"
        /> -->
    <dataNode name="dn1" dataHost="localhost1" database="db1"/>
    <dataNode name="dn2" dataHost="localhost1" database="db2"/>
    <dataNode name="dn3" dataHost="localhost1" database="db3"/>
    <dataNode name="dn4" dataHost="localhost1" database="db4"/>
    <dataHost name="localhost1" maxCon="1000" minCon="10" balance="0" switchType="1" slaveThreshold="100">
        <heartbeat>show slave status</heartbeat>
        <!-- can have multi write hosts -->
        <writeHost host="hostM1" url="10.186.24.37:3306" user="root"
                   password="123456">
        </writeHost>
        
    </dataHost>
</dble:schema>

rule.xml

default

server.xml

default

  • steps:
    execute sql
    SELECT
    BUSIDATE AS occurDate,
    ZONENO AS zoneNo,
    BRNO AS brNo,
    TELLERNO AS tellerNo
    FROM
    (
    SELECT
    F.BUSIDATE,
    F.ZONENO,
    F.BRNO,
    F.TELLERNO
    FROM
    BAMS_FLOW_LOG F
    where F.id = 1
    UNION ALL
    SELECT
    '20180716' AS BUSIDATE,
    '00119' AS ZONENO,
    '260' AS BRNO,
    '34890' AS TELLERNO
    ) T
  • expect result:
    +-----------+--------+----------+----------+
    | occurDate | zoneNo | brNo | tellerNo |
    +-----------+--------+----------+----------+
    | 20180716 | 00119 | 260 | 34890 |
    +-----------+--------+----------+----------+
  • real result:
    +-----------+--------+----------+----------+
    | occurDate | zoneNo | brNo | tellerNo |
    +-----------+--------+----------+----------+
    | 00119 | 260 | 20180716 | 34890 |
    +-----------+--------+----------+----------+

/label ~BUG

Metadata

Metadata

Assignees

Labels

resolveproblem has been fixed by developerverifiedissue's resolve was verified by tester

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions