github.com/dolthub/go-mysql-server@v0.18.0/enginetest/queries/call_asof_queries.go (about)

     1  // Copyright 2023 Dolthub, Inc.
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  package queries
    16  
    17  import "github.com/dolthub/go-mysql-server/sql"
    18  
    19  var CallAsofScripts = []ScriptTest{
    20  	{
    21  		Name: "AS OF propagates to nested CALLs",
    22  		SetUpScript: []string{
    23  			"CREATE PROCEDURE p1() BEGIN CALL p2(); END",
    24  			"CREATE PROCEDURE p1a() BEGIN CALL p2() AS OF '2019-01-01'; END",
    25  			"CREATE PROCEDURE p1b() BEGIN CALL p2a(); END",
    26  			"CREATE PROCEDURE p2() BEGIN SELECT * FROM myhistorytable; END",
    27  			"CREATE PROCEDURE p2a() BEGIN SELECT * FROM myhistorytable AS OF '2019-01-02'; END",
    28  		},
    29  		Assertions: []ScriptTestAssertion{
    30  			{
    31  				Query: "CALL p1();",
    32  				Expected: []sql.Row{
    33  					{int64(1), "first row, 3", "1"},
    34  					{int64(2), "second row, 3", "2"},
    35  					{int64(3), "third row, 3", "3"},
    36  				},
    37  			},
    38  			{
    39  				Query: "CALL p1a();",
    40  				Expected: []sql.Row{
    41  					{int64(1), "first row, 1"},
    42  					{int64(2), "second row, 1"},
    43  					{int64(3), "third row, 1"},
    44  				},
    45  			},
    46  			{
    47  				Query: "CALL p1b();",
    48  				Expected: []sql.Row{
    49  					{int64(1), "first row, 2"},
    50  					{int64(2), "second row, 2"},
    51  					{int64(3), "third row, 2"},
    52  				},
    53  			},
    54  			{
    55  				Query: "CALL p2();",
    56  				Expected: []sql.Row{
    57  					{int64(1), "first row, 3", "1"},
    58  					{int64(2), "second row, 3", "2"},
    59  					{int64(3), "third row, 3", "3"},
    60  				},
    61  			},
    62  			{
    63  				Query: "CALL p2a();",
    64  				Expected: []sql.Row{
    65  					{int64(1), "first row, 2"},
    66  					{int64(2), "second row, 2"},
    67  					{int64(3), "third row, 2"},
    68  				},
    69  			},
    70  			{
    71  				Query: "CALL p1() AS OF '2019-01-01';",
    72  				Expected: []sql.Row{
    73  					{int64(1), "first row, 1"},
    74  					{int64(2), "second row, 1"},
    75  					{int64(3), "third row, 1"},
    76  				},
    77  			},
    78  			{
    79  				Query: "CALL p1a() AS OF '2019-01-03';",
    80  				Expected: []sql.Row{
    81  					{int64(1), "first row, 1"},
    82  					{int64(2), "second row, 1"},
    83  					{int64(3), "third row, 1"},
    84  				},
    85  			},
    86  			{
    87  				Query: "CALL p1b() AS OF '2019-01-03';",
    88  				Expected: []sql.Row{
    89  					{int64(1), "first row, 2"},
    90  					{int64(2), "second row, 2"},
    91  					{int64(3), "third row, 2"},
    92  				},
    93  			},
    94  			{
    95  				Query: "CALL p2() AS OF '2019-01-01';",
    96  				Expected: []sql.Row{
    97  					{int64(1), "first row, 1"},
    98  					{int64(2), "second row, 1"},
    99  					{int64(3), "third row, 1"},
   100  				},
   101  			},
   102  			{
   103  				Query: "CALL p2a() AS OF '2019-01-03';",
   104  				Expected: []sql.Row{
   105  					{int64(1), "first row, 2"},
   106  					{int64(2), "second row, 2"},
   107  					{int64(3), "third row, 2"},
   108  				},
   109  			},
   110  		},
   111  	},
   112  }