Exemple #1
0
 def test_create_index_fails(self, sql):
     with pytest.raises(KeyError):
         create_index(sql, 'z', name='zidx')
     with pytest.raises(ValueError):
         create_index(sql, 'x')
     with pytest.raises(ValueError):
         create_index(sql, 'z')
Exemple #2
0
def test_create_index_fails(sql):
    with pytest.raises(KeyError):
        create_index(sql, "z", name="zidx")
    with pytest.raises(ValueError):
        create_index(sql, "x")
    with pytest.raises(ValueError):
        create_index(sql, "z")
def test_create_index(pyt):
    create_index(pyt, 'id')
    assert 'id' in pyt.colindexes
def test_create_multiple_indexes_fails(pyt):
    with pytest.raises(ValueError):
        create_index(pyt, ['id', 'blarg'])

    with pytest.raises(ValueError):
        create_index(pyt, ['foo', 'bar'])
def test_create_index(pyt):
    create_index(pyt, 'id')
    assert 'id' in pyt.colindexes
Exemple #6
0
 def test_fails_when_using_not_list_of_tuples_or_strings(self, mongo_idx):
     from pymongo import DESCENDING
     with pytest.raises(TypeError):
         create_index(mongo_idx.tmp_collection, [['id', DESCENDING]])
Exemple #7
0
 def test_create_composite_index(self, mongo_idx):
     create_index(mongo_idx.tmp_collection, ['id', 'amount'], name='c_idx')
     assert 'c_idx' in mongo_idx.tmp_collection.index_information()
Exemple #8
0
 def test_create_index_unique(self, sql):
     create_index(sql, 'y', name='y_idx', unique=True)
     assert len(sql.indexes) == 1
     idx = first(sql.indexes)
     assert idx.unique
     assert idx.columns.y == sql.c.y
Exemple #9
0
 def test_create_index(self, mongo_idx):
     create_index(mongo_idx.tmp_collection, 'id', name='idx_id')
     assert 'idx_id' in mongo_idx.tmp_collection.index_information()
Exemple #10
0
 def test_create_composite_index(self, mongo_idx):
     create_index(mongo_idx.tmp_collection, ['id', 'amount'])
     assert 'id_1_amount_1' in mongo_idx.tmp_collection.index_information()
Exemple #11
0
from blaze import CSV, Table
csv = CSV('hmda_lar-2012.csv')  # Open the CSV file
t = Table(csv)                  # Interact with CSV file using interactive Table object

columns = ['action_taken_name', 'agency_abbr', 'applicant_ethnicity_name',
           'applicant_race_name_1', 'applicant_sex_name', 'county_name',
           'loan_purpose_name', 'state_abbr']

t = t[columns]

t2 = t[t.state_abbr == 'NY']

from blaze import into, by
from pandas import DataFrame
# Group on action_taken_name, count each group
print into(DataFrame, t2.action_taken_name.count_values())

from blaze import SQL
sql = SQL('sqlite:///hmda.db', 'data', schema=t.schema) # A SQLite database
into(sql, t)  # Migrate data

sqlTable = Table(sql)

from blaze import create_index
create_index(sql, 'state_abbr', name='state_abbr_index')

t2 = sqlTable[sqlTable.state_abbr == 'NY']

print into(DataFrame, t2.action_taken_name.count_values())
Exemple #12
0
def test_composite_index_fails_with_existing_columns(sql):
    with pytest.raises(KeyError):
        create_index(sql, ["x", "z", "bizz"], name="idx_name")
Exemple #13
0
def test_composite_index_fails(sql):
    with pytest.raises(KeyError):
        create_index(sql, ["z", "bizz"], name="idx_name")
Exemple #14
0
def test_composite_index(sql):
    create_index(sql, ["x", "y"], name="idx_xy")
    with pytest.raises(OperationalError):
        create_index(sql, ["x", "y"], name="idx_xy")
Exemple #15
0
def test_create_index_unique(sql):
    create_index(sql, "y", name="y_idx", unique=True)
    assert len(sql.data.indexes) == 1
    idx = first(sql.data.indexes)
    assert idx.unique
    assert idx.columns.y == sql.data.c.y
def test_create_multiple_indexes_fails(pyt):
    with pytest.raises(ValueError):
        create_index(pyt, ['id', 'blarg'])

    with pytest.raises(ValueError):
        create_index(pyt, ['foo', 'bar'])
Exemple #17
0
 def test_create_index(self, sql):
     create_index(sql, 'x', name='idx')
     with pytest.raises(OperationalError):
         create_index(sql, 'x', name='idx')
Exemple #18
0
 def test_create_index_single_element_list(self, mongo_idx):
     create_index(mongo_idx.tmp_collection, ['id'], name='idx_id')
     assert 'idx_id' in mongo_idx.tmp_collection.index_information()
Exemple #19
0
 def test_composite_index_fails(self, sql):
     with pytest.raises(KeyError):
         create_index(sql, ['z', 'bizz'], name='idx_name')
Exemple #20
0
 def test_create_composite_index(self, mongo_idx):
     create_index(mongo_idx.tmp_collection, ['id', 'amount'], name='c_idx')
     assert 'c_idx' in mongo_idx.tmp_collection.index_information()
Exemple #21
0
 def test_create_index_single_element_list(self, mongo_idx):
     create_index(mongo_idx.tmp_collection, ['id'], name='idx_id')
     assert 'idx_id' in mongo_idx.tmp_collection.index_information()
Exemple #22
0
 def test_create_composite_index_params(self, mongo_idx):
     from pymongo import ASCENDING, DESCENDING
     create_index(mongo_idx.tmp_collection, [('id', ASCENDING),
                                             ('amount', DESCENDING)],
                  name='c_idx')
     assert 'c_idx' in mongo_idx.tmp_collection.index_information()
Exemple #23
0
 def test_create_composite_index_params(self, mongo_idx):
     from pymongo import ASCENDING, DESCENDING
     create_index(mongo_idx.tmp_collection,
                  [('id', ASCENDING), ('amount', DESCENDING)],
                  name='c_idx')
     assert 'c_idx' in mongo_idx.tmp_collection.index_information()
Exemple #24
0
 def test_fails_when_using_not_list_of_tuples_or_strings(self, mongo_idx):
     from pymongo import DESCENDING
     with pytest.raises(TypeError):
         create_index(mongo_idx.tmp_collection, [['id', DESCENDING]])
Exemple #25
0
 def test_create_index_with_unique(self, mongo_idx):
     coll = mongo_idx.tmp_collection
     create_index(coll, 'id', unique=True, name='c_idx')
     assert coll.index_information()['c_idx']['unique']
Exemple #26
0
 def test_create_index_with_unique(self, mongo_idx):
     coll = mongo_idx.tmp_collection
     create_index(coll, 'id', unique=True, name='c_idx')
     assert coll.index_information()['c_idx']['unique']
def test_create_multiple_indexes(pyt):
    create_index(pyt, ['id', 'amount'])
    assert len(pyt.colindexes) == 2
    assert 'id' in pyt.colindexes
    assert 'amount' in pyt.colindexes
def test_create_index(pyt):
    create_index(pyt, "id")
    assert "id" in pyt.colindexes
def test_create_index_fails(pyt):
    with pytest.raises(AttributeError):
        create_index(pyt, 'no column here!')
def test_create_multiple_indexes(pyt):
    create_index(pyt, ["id", "amount"])
    assert len(pyt.colindexes) == 2
    assert "id" in pyt.colindexes
    assert "amount" in pyt.colindexes
def test_create_multiple_indexes(pyt):
    create_index(pyt, ['id', 'amount'])
    assert len(pyt.colindexes) == 2
    assert 'id' in pyt.colindexes
    assert 'amount' in pyt.colindexes
def test_create_multiple_indexes_fails(pyt):
    with pytest.raises(ValueError):
        create_index(pyt, ["id", "blarg"])

    with pytest.raises(ValueError):
        create_index(pyt, ["foo", "bar"])
def test_create_index_fails(pyt):
    with pytest.raises(AttributeError):
        create_index(pyt, 'no column here!')
Exemple #34
0
def test_create_index(sql, cols):
    create_index(sql, cols, name='idx')
    with pytest.raises(OperationalError):
        create_index(sql, cols, name='idx')
Exemple #35
0
def test_create_index(sql, cols):
    create_index(sql, cols, name='idx')
    with pytest.raises(OperationalError):
        create_index(sql, cols, name='idx')
Exemple #36
0
 def test_create_composite_index(self, mongo_idx):
     create_index(mongo_idx.tmp_collection, ['id', 'amount'])
     assert 'id_1_amount_1' in mongo_idx.tmp_collection.index_information()
Exemple #37
0
 def test_composite_index(self, sql):
     create_index(sql, ['x', 'y'], name='idx_xy')
     with pytest.raises(OperationalError):
         create_index(sql, ['x', 'y'], name='idx_xy')
Exemple #38
0
 def test_create_index(self, mongo_idx):
     create_index(mongo_idx.tmp_collection, 'id', name='idx_id')
     assert 'idx_id' in mongo_idx.tmp_collection.index_information()
Exemple #39
0
 def test_composite_index_fails_with_existing_columns(self, sql):
     with pytest.raises(KeyError):
         create_index(sql, ['x', 'z', 'bizz'], name='idx_name')
Exemple #40
0
 def test_create_composite_index_params(self, mongo_idx):
     create_index(mongo_idx.tmp_collection,
                  [('id', ASCENDING), ('amount', DESCENDING)])
     assert 'id_1_amount_-1' in mongo_idx.tmp_collection.index_information()