###Deephaven
Deephaven test::DeephavenStore
(
    Table stockTrades
    (
        TradeID: Integer,
        StockSymbol: String,
        Price: Float,
        Quantity: Integer,
        TradeTime: DateTime,
        City: String,
        IsBuy: Boolean
    )
)

###Pure

function test::basicSelect(): Any[*]
{
  #>{test::DeephavenStore.stockTrades}#->select()->from(test::DeephavenRuntime)
}

function test::basicSelectOneCol(): Any[*]
{
  #>{test::DeephavenStore.stockTrades}#->select(~[StockSymbol])->from(test::DeephavenRuntime)
}

function test::basicSelectTwoCols(): Any[*]
{
  #>{test::DeephavenStore.stockTrades}#->select(~[City, Quantity])->from(test::DeephavenRuntime)
}

function test::basicWhere(): Any[*]
{
  #>{test::DeephavenStore.stockTrades}#->filter(c | $c.StockSymbol == 'GOOG')->from(test::DeephavenRuntime)
}

function test::basicWhereWithSelect(): Any[*]
{
  #>{test::DeephavenStore.stockTrades}#->filter(c | $c.City == 'New York')->select(~[StockSymbol])->from(test::DeephavenRuntime)
}

function test::basicTwoWhereWithSelect(): Any[*]
{
  #>{test::DeephavenStore.stockTrades}#->filter(c | $c.City == 'New York')->filter(c | $c.IsBuy == true)->select(~[StockSymbol])->from(test::DeephavenRuntime)
}

function test::basicTwoWhereWithAnd(): Any[*]
{
  #>{test::DeephavenStore.stockTrades}#->filter(c | ($c.City == 'New York') && ($c.StockSymbol == 'AAPL'))->from(test::DeephavenRuntime)
}

function test::basicTwoWhereWithOr(): Any[*]
{
  #>{test::DeephavenStore.stockTrades}#->filter(c | ($c.City == 'London') || ($c.StockSymbol == 'MSFT'))->from(test::DeephavenRuntime)
}

function test::basicWhereWithIn(): Any[*]
{
  #>{test::DeephavenStore.stockTrades}#->filter(c | $c.City->in(['London', 'Tokyo']))->from(test::DeephavenRuntime)
}

function test::basicWhereWithNotEqual(): Any[*]
{
  #>{test::DeephavenStore.stockTrades}#->filter(c | $c.City != 'New York')->from(test::DeephavenRuntime)
}

function test::basicSort(): Any[*]
{
  #>{test::DeephavenStore.stockTrades}#->sort([~City->ascending(), ~Price->descending()])->from(test::DeephavenRuntime)
}


// Combination of functions

function test::filterWithEquality(): Any[*]
{
  #>{test::DeephavenStore.stockTrades}#->filter(x|($x.IsBuy == true) && ($x.StockSymbol == 'AAPL'))->select(~[TradeID,StockSymbol,Price,Quantity,TradeTime])->from(test::DeephavenRuntime)
}

function test::filterWithNotAndOr(): Any[*]
{
  #>{test::DeephavenStore.stockTrades}#->filter(x|(!($x.City->in( ['London', 'Tokyo'] ))) || ($x.Price > 200))->select(~[TradeID,StockSymbol,Price,City])->from(test::DeephavenRuntime)
}

function test::filterWithOrAndSelect(): meta::pure::metamodel::type::Any[*]
{
  #>{test::DeephavenStore.stockTrades}#->filter(x|($x.Price > 400) || ($x.Quantity > 200))->select(~[TradeID,StockSymbol,Price,Quantity])->from(test::DeephavenRuntime)
}

function test::multiConditionFilterWithAnd(): meta::pure::metamodel::type::Any[*]
{
  #>{test::DeephavenStore.stockTrades}#->filter(x|(($x.IsBuy == true) && ($x.City == 'New York')) &&($x.Quantity > 100))->select(~[TradeID,StockSymbol,Quantity,Price])->from(test::DeephavenRuntime)
}

function test::SelectWithExpressionAndFilter(): meta::pure::metamodel::type::Any[*]
{
  // #>{test::DeephavenStore.stockTrades}#->filter(x|$x.TradeTime > %2025-03-06T04:33:00)->select(~[TradeID,StockSymbol,Price,TradeTime])->from(test::DeephavenRuntime)
  // #>{test::DeephavenStore.stockTrades}#->filter(x|$x.TradeTime > %2025-03-06T04:33:00+0000)->select(~[TradeID,StockSymbol,Price,TradeTime])->from(test::DeephavenRuntime)
  // #>{test::DeephavenStore.stockTrades}#->filter(x|$x.TradeTime > %2025-03-06T04:33:00Z)->select(~[TradeID,StockSymbol,Price,TradeTime])->from(test::DeephavenRuntime)
  // #>{test::DeephavenStore.stockTrades}#->filter(x|$x.TradeTime > %2025-03-06T04:33:00 ET)->select(~[TradeID,StockSymbol,Price,TradeTime])->from(test::DeephavenRuntime)
 
  #>{test::DeephavenStore.stockTrades}#->filter(x|$x.TradeTime > %2025-03-06T09:33:00)->select(~[TradeID,StockSymbol,Price,TradeTime])->from(test::DeephavenRuntime)
}


###Connection
DeephavenConnection test::DeephavenConnection
{
    store: test::DeephavenStore;
    serverUrl: 'http://localhost:10000'
    authentication: # PSK {
        psk: 'myStaticPSK';
    }#;
}

###Runtime
Runtime test::DeephavenRuntime
{
  mappings:
  [
  ];
  connections:
  [
    test::DeephavenStore:
    [
      connection: test::DeephavenConnection
    ]
  ];
}