def setUp(self) -> None:
     with ugp_exclusive_lock():
         self.test_table = time_table("00:00:00.001").update(
             ["X=i%11"]).sort("X").tail(16)
         source_table = time_table("00:00:00.001").update(
             ["TS=currentTime()"])
         self.test_table2 = time_window(source_table,
                                        ts_col="TS",
                                        window=10**7,
                                        bool_col="InWindow")
Exemple #2
0
    def test_time_table(self):
        t = time_table("00:00:01")
        self.assertEqual(1, len(t.columns))
        self.assertTrue(t.is_refreshing)

        t = time_table("00:00:01", start_time="2021-11-06T13:21:00 NY")
        self.assertEqual(1, len(t.columns))
        self.assertTrue(t.is_refreshing)
        self.assertEqual(
            "2021-11-06T13:21:00.000000000 NY",
            t.j_table.getColumnSource("Timestamp").get(0).toString())
Exemple #3
0
    def test_merge_sorted_error(self):
        t1 = time_table("00:00:01")
        t2 = self.test_table.update(
            formulas=["Timestamp=io.deephaven.time.DateTime.now()"])
        with self.assertRaises(DHError) as cm:
            mt = merge_sorted(order_by="a", tables=[t1, t2])
            self.assertFalse(mt.is_refreshing)

        self.assertIn("UnsupportedOperationException", cm.exception.root_cause)
Exemple #4
0
def ticking_crypto_milliseconds(interval: int):
    from deephaven import time_table
    from deephaven_legacy.DateTimeUtils import currentTime, minus
    t = time_table('00:00:00.' + str(interval * 1000).zfill(6),minus(currentTime(), 1800000000000)).update(formulas = [
        'Id=(int)random.randint(12000000,1100000000)', 'B=random.randint(0,1)', 'C=random.randint(0,50)',
        'D= ((int)(random.randint(0,100))/100.0 - 0.5) * 20000.0', 'Instrument=ct_symbols[((int)ct_distributor(ct_x))-1]',
        'Size=(((int)random.randint(1, 100)) / ((int)random.randint(1, 100)))',
        'Price=(double)ct_pricer(Instrument, D)', 'Exchange = ct_exchanges[(int)C%ct_y]',
        'Date = formatDate(Timestamp, TZ_NY)']) \
        .drop_columns(cols = ['B', 'C', 'D']) \
        .move_columns_up(cols = ['Date', 'Timestamp', 'Id', 'Instrument', 'Exchange', 'Price', 'Size'])
    return t
    def test_time_window(self):
        with ugp_exclusive_lock():
            source_table = time_table("00:00:00.01").update(
                ["TS=currentTime()"])
            t = time_window(source_table,
                            ts_col="TS",
                            window=10**8,
                            bool_col="InWindow")

        self.assertEqual("InWindow", t.columns[-1].name)
        self.wait_ticking_table_update(t, row_count=20, timeout=60)
        self.assertIn("true", t.to_string(1000))
        self.assertIn("false", t.to_string(1000))
Exemple #6
0
def create_table():
    with ugp_exclusive_lock():
        return time_table("00:00:00.001").update(["X=i%11"]).sort("X").tail(16)
Exemple #7
0
    def test_time_table_error(self):
        with self.assertRaises(DHError) as cm:
            t = time_table("00:0a:01")

        self.assertIn("IllegalArgumentException", cm.exception.root_cause)
Exemple #8
0
 def setUp(self) -> None:
     with self.ugp_lock_exclusive():
         self.table = time_table("00:00:01").update(["X=i"]).tail(5)
     self.table_change_processed = None