Ejemplo n.º 1
0
        public void ErrorTest()
        {
            using (DbConnection Conn = new PrestoSqlDbConnection())
            {
                Conn.ConnectionString = "http://*****:*****@"ERROR HERE!";


                    try
                    {
                        using (DbDataReader Reader = Cmd.ExecuteReader())
                        {
                            while (Reader.Read())
                            {
                                for (int i = 0; i < Reader.FieldCount; i++)
                                {
                                    Console.Write(Reader[i]);
                                }
                            }
                        }

                        Assert.Fail();
                    }
                    catch (PrestoSqlException ex)
                    {
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public void SecondTest()
        {
            using (DbConnection Conn = new PrestoSqlDbConnection())
            {
                Conn.ConnectionString = "http://*****:*****@"SELECT orderpriority, SUM(totalprice) AS totalprice
FROM tpch.sf1.orders AS O
INNER JOIN tpch.sf1.customer AS C ON O.custkey = C.custkey 
GROUP BY orderpriority ORDER BY orderpriority";

                    using (DbDataReader Reader = Cmd.ExecuteReader())
                    {
                        while (Reader.Read())
                        {
                            for (int i = 0; i < Reader.FieldCount; i++)
                            {
                                Console.Write(Reader[i]);
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 3
0
        public void FirstTest()
        {
            using (DbConnection Conn = new PrestoSqlDbConnection())
            {
                Conn.ConnectionString = "http://localhost:8080";
                Conn.Open();

                using (DbCommand Cmd = Conn.CreateCommand())
                {
                    Cmd.CommandText = "VALUES (true, TINYINT '1', SMALLINT '1', INTEGER '1', BIGINT '1', REAL '1.0', DOUBLE '1.0', DECIMAL '123.456', VARCHAR 'Hello World!', CHAR 's', VARBINARY '1111', DATE '2019-01-01', TIME '01:02:03.456', TIME '01:02:03.456 America/Los_Angeles', TIMESTAMP '2001-08-22 03:04:05.321', TIMESTAMP '2001-08-22 03:04:05.321 America/Los_Angeles', INTERVAL '3' MONTH, INTERVAL '2' DAY, ARRAY[1, 2, 3], MAP(ARRAY['foo', 'bar'], ARRAY[1, 2]), CAST(ROW(1, 2.0) AS ROW(x BIGINT, y DOUBLE)), IPADDRESS '10.0.0.1', IPADDRESS '2001:db8::1')";

                    using (DbDataReader Reader = Cmd.ExecuteReader())
                    {
                        if (Reader.Read())
                        {
                            for (int i = 0; i < Reader.FieldCount; i++)
                            {
                                Type   T     = Reader.GetFieldType(i);
                                object Value = Reader.GetValue(i);
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 4
0
        public void ErrorTest()
        {
            using DbConnection conn = new PrestoSqlDbConnection();
            conn.ConnectionString   = "http://*****:*****@"ERROR HERE!";


            try
            {
                using (var reader = cmd.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        for (var i = 0; i < reader.FieldCount; i++)
                        {
                            var y = reader[i];
                            //_helper.WriteLine();
                        }
                    }
                }

                Assert.False(false);
            }
            catch (PrestoSqlException ex)
            {
            }
        }
Ejemplo n.º 5
0
        public void FilterTest()
        {
            using DbConnection conn = new PrestoSqlDbConnection
                  {
                      ConnectionString = "http://localhost:8081"
                  };
            conn.Open();

            using var cmd   = conn.CreateCommand();
            cmd.CommandText = "select __producer_name__, __sequence_id__ from pulsar.\"public/default\".students";

            using var reader = cmd.ExecuteReader();
            while (reader.Read())
            {
                var row = new List <string>();
                for (var i = 0; i < reader.FieldCount; i++)
                {
                    try
                    {
                        var value = reader.GetValue(i).ToString();
                        var col   = reader.GetName(i);
                        row.Add($"{col} : {value}");
                    }
                    catch (Exception e)
                    {
                    }
                }
                _helper.WriteLine(string.Join(" - ", row));
            }
        }
Ejemplo n.º 6
0
        public void SingleResultTest()
        {
            using (DbConnection Conn = new PrestoSqlDbConnection())
            {
                Conn.ConnectionString = "http://localhost:8080";
                Conn.Open();

                using (DbCommand Cmd = Conn.CreateCommand())
                {
                    Cmd.CommandText = "SELECT 1";

                    int v = Convert.ToInt32(Cmd.ExecuteScalar());

                    if (v != 1)
                    {
                        Assert.Fail("Invalid return value");
                    }
                }
            }
        }
Ejemplo n.º 7
0
        public void SingleResultTest()
        {
            using DbConnection conn = new PrestoSqlDbConnection
                  {
                      ConnectionString = "http://localhost:8081"
                  };
            conn.Open();

            using var cmd   = conn.CreateCommand();
            cmd.CommandText = "select SequenceNr from pulsar.\"public/default\".journal WHERE PersistenceId = 'sampleActor' ORDER BY SequenceNr DESC LIMIT 1";

            var v = Convert.ToInt32(cmd.ExecuteScalar());

            _helper.WriteLine(v.ToString());

            if (v <= 1)
            {
                Assert.False(false, "Invalid return value");
            }
        }
Ejemplo n.º 8
0
        public void Schema()
        {
            using DbConnection conn = new PrestoSqlDbConnection
                  {
                      ConnectionString = "http://localhost:8081"
                  };
            conn.Open();

            using var cmd   = conn.CreateCommand();
            cmd.CommandText = "show tables in pulsar.\"public/default\"";

            using var reader = cmd.ExecuteReader();
            var rows = reader.RecordsAffected;

            while (reader.Read())
            {
                for (var i = 0; i < reader.FieldCount; i++)
                {
                    var T     = reader.GetFieldType(i);
                    var value = reader.GetValue(i);
                    _helper.WriteLine(value.ToString());
                }
            }
        }
Ejemplo n.º 9
0
        public void FirstTest()
        {
            using DbConnection conn = new PrestoSqlDbConnection
                  {
                      ConnectionString = "http://localhost:8081"
                  };
            conn.Open();

            using var cmd   = conn.CreateCommand();
            cmd.CommandText = "select SequenceNr from pulsar.\"public/default\".journal WHERE PersistenceId = 'sampleActor' ORDER BY SequenceNr DESC LIMIT 1";

            using var reader = cmd.ExecuteReader();
            var rows = reader.RecordsAffected;

            if (reader.Read())
            {
                for (var i = 0; i < reader.FieldCount; i++)
                {
                    var T     = reader.GetFieldType(i);
                    var value = reader.GetValue(i);
                    _helper.WriteLine(value.ToString());
                }
            }
        }