Пример #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')
Пример #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")
Пример #3
0
def test_create_index(pyt):
    create_index(pyt, 'id')
    assert 'id' in pyt.colindexes
Пример #4
0
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'])
Пример #5
0
def test_create_index(pyt):
    create_index(pyt, 'id')
    assert 'id' in pyt.colindexes
Пример #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]])
Пример #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()
Пример #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
Пример #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()
Пример #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()
Пример #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())
Пример #12
0
def test_composite_index_fails_with_existing_columns(sql):
    with pytest.raises(KeyError):
        create_index(sql, ["x", "z", "bizz"], name="idx_name")
Пример #13
0
def test_composite_index_fails(sql):
    with pytest.raises(KeyError):
        create_index(sql, ["z", "bizz"], name="idx_name")
Пример #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")
Пример #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
Пример #16
0
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'])
Пример #17
0
 def test_create_index(self, sql):
     create_index(sql, 'x', name='idx')
     with pytest.raises(OperationalError):
         create_index(sql, 'x', name='idx')
Пример #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()
Пример #19
0
 def test_composite_index_fails(self, sql):
     with pytest.raises(KeyError):
         create_index(sql, ['z', 'bizz'], name='idx_name')
Пример #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()
Пример #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()
Пример #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()
Пример #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()
Пример #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]])
Пример #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']
Пример #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']
Пример #27
0
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
Пример #28
0
def test_create_index(pyt):
    create_index(pyt, "id")
    assert "id" in pyt.colindexes
Пример #29
0
def test_create_index_fails(pyt):
    with pytest.raises(AttributeError):
        create_index(pyt, 'no column here!')
Пример #30
0
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
Пример #31
0
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
Пример #32
0
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"])
Пример #33
0
def test_create_index_fails(pyt):
    with pytest.raises(AttributeError):
        create_index(pyt, 'no column here!')
Пример #34
0
def test_create_index(sql, cols):
    create_index(sql, cols, name='idx')
    with pytest.raises(OperationalError):
        create_index(sql, cols, name='idx')
Пример #35
0
def test_create_index(sql, cols):
    create_index(sql, cols, name='idx')
    with pytest.raises(OperationalError):
        create_index(sql, cols, name='idx')
Пример #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()
Пример #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')
Пример #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()
Пример #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')
Пример #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()