alf-core 0.14.0 → 0.15.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +10 -0
- data/Gemfile +2 -8
- data/Gemfile.lock +9 -17
- data/examples/operators/frame.alf +2 -0
- data/lib/alf-core.rb +24 -22
- data/lib/{alf-adapter/alf → alf}/adapter.rb +0 -0
- data/lib/{alf-adapter/alf → alf}/adapter/connection.rb +4 -10
- data/lib/{alf-adapter/alf → alf}/adapter/connection/schema_cached.rb +0 -0
- data/lib/{alf-adapter-fs/alf → alf}/adapter/folder.rb +0 -0
- data/lib/{alf-adapter-fs/alf → alf}/adapter/folder/connection.rb +3 -2
- data/lib/{alf-adapter-fs/alf → alf}/adapter/fs.rb +0 -0
- data/lib/{alf-aggregator/alf → alf}/aggregator.rb +12 -9
- data/lib/{alf-aggregator/alf → alf}/aggregator/avg.rb +0 -0
- data/lib/{alf-aggregator/alf → alf}/aggregator/collect.rb +0 -0
- data/lib/{alf-aggregator/alf → alf}/aggregator/concat.rb +0 -0
- data/lib/{alf-aggregator/alf → alf}/aggregator/count.rb +0 -0
- data/lib/{alf-aggregator/alf → alf}/aggregator/max.rb +0 -0
- data/lib/{alf-aggregator/alf → alf}/aggregator/min.rb +0 -0
- data/lib/{alf-aggregator/alf → alf}/aggregator/stddev.rb +0 -0
- data/lib/{alf-aggregator/alf → alf}/aggregator/sum.rb +0 -0
- data/lib/{alf-aggregator/alf → alf}/aggregator/variance.rb +0 -0
- data/lib/{alf-algebra/alf → alf}/algebra.rb +1 -0
- data/lib/{alf-algebra/alf → alf}/algebra/operand.rb +13 -6
- data/lib/{alf-algebra/alf → alf}/algebra/operand/fake.rb +18 -4
- data/lib/alf/algebra/operand/named.rb +65 -0
- data/lib/{alf-algebra/alf → alf}/algebra/operand/proxy.rb +7 -3
- data/lib/{alf-algebra/alf → alf}/algebra/operator.rb +40 -12
- data/lib/{alf-algebra/alf → alf}/algebra/operator/autonum.rb +9 -1
- data/lib/{alf-algebra/alf → alf}/algebra/operator/clip.rb +9 -1
- data/lib/{alf-algebra/alf → alf}/algebra/operator/coerce.rb +9 -1
- data/lib/{alf-algebra/alf → alf}/algebra/operator/compact.rb +8 -1
- data/lib/{alf-algebra/alf → alf}/algebra/operator/defaults.rb +8 -1
- data/lib/{alf-algebra/alf → alf}/algebra/operator/extend.rb +9 -1
- data/lib/{alf-algebra/alf → alf}/algebra/operator/frame.rb +12 -1
- data/lib/{alf-algebra/alf → alf}/algebra/operator/generator.rb +8 -1
- data/lib/{alf-algebra/alf → alf}/algebra/operator/group.rb +10 -1
- data/lib/{alf-algebra/alf → alf}/algebra/operator/hierarchize.rb +8 -0
- data/lib/{alf-algebra/alf → alf}/algebra/operator/intersect.rb +9 -1
- data/lib/{alf-algebra/alf → alf}/algebra/operator/join.rb +9 -1
- data/lib/{alf-algebra/alf → alf}/algebra/operator/matching.rb +10 -2
- data/lib/{alf-algebra/alf → alf}/algebra/operator/minus.rb +9 -1
- data/lib/{alf-algebra/alf → alf}/algebra/operator/not_matching.rb +9 -1
- data/lib/{alf-algebra/alf → alf}/algebra/operator/page.rb +11 -1
- data/lib/{alf-algebra/alf → alf}/algebra/operator/project.rb +9 -1
- data/lib/{alf-algebra/alf → alf}/algebra/operator/quota.rb +12 -1
- data/lib/{alf-algebra/alf → alf}/algebra/operator/rank.rb +11 -2
- data/lib/{alf-algebra/alf → alf}/algebra/operator/rename.rb +10 -1
- data/lib/{alf-algebra/alf → alf}/algebra/operator/restrict.rb +12 -2
- data/lib/{alf-algebra/alf → alf}/algebra/operator/sort.rb +9 -1
- data/lib/{alf-algebra/alf → alf}/algebra/operator/summarize.rb +10 -1
- data/lib/{alf-algebra/alf → alf}/algebra/operator/ungroup.rb +11 -1
- data/lib/{alf-algebra/alf → alf}/algebra/operator/union.rb +9 -1
- data/lib/{alf-algebra/alf → alf}/algebra/operator/unwrap.rb +13 -1
- data/lib/{alf-algebra/alf → alf}/algebra/operator/wrap.rb +10 -1
- data/lib/alf/algebra/shortcut.rb +40 -0
- data/lib/alf/algebra/shortcut/allbut.rb +25 -0
- data/lib/{alf-algebra/alf → alf}/algebra/support.rb +2 -1
- data/lib/{alf-algebra/alf → alf}/algebra/support/binary.rb +0 -0
- data/lib/{alf-algebra/alf → alf}/algebra/support/classification.rb +0 -0
- data/lib/{alf-algebra/alf → alf}/algebra/support/compiler.rb +0 -0
- data/lib/{alf-algebra/alf → alf}/algebra/support/experimental.rb +0 -0
- data/lib/{alf-algebra/alf → alf}/algebra/support/non_relational.rb +0 -0
- data/lib/{alf-algebra/alf → alf}/algebra/support/nullary.rb +0 -0
- data/lib/{alf-algebra/alf → alf}/algebra/support/relational.rb +0 -0
- data/lib/{alf-algebra/alf → alf}/algebra/support/rewriter.rb +4 -0
- data/lib/{alf-algebra/alf → alf}/algebra/support/signature.rb +7 -8
- data/lib/alf/algebra/support/type_check.rb +51 -0
- data/lib/{alf-algebra/alf → alf}/algebra/support/unary.rb +0 -0
- data/lib/{alf-algebra/alf → alf}/algebra/support/visitor.rb +2 -1
- data/lib/{alf-algebra/alf → alf}/algebra/support/with_ordering.rb +0 -0
- data/lib/alf/compiler.rb +57 -0
- data/lib/alf/compiler/cog.rb +39 -0
- data/lib/alf/compiler/default.rb +168 -0
- data/lib/alf/compiler/plan.rb +77 -0
- data/lib/{alf-core → alf/core}/loader.rb +0 -0
- data/lib/{alf-core → alf/core}/version.rb +1 -1
- data/lib/{alf-database/alf → alf}/database.rb +0 -0
- data/lib/{alf-database/alf → alf}/database/connection.rb +10 -52
- data/lib/{alf-database/alf → alf}/database/options.rb +2 -5
- data/lib/{alf-core → alf}/dsl.rb +4 -4
- data/lib/{alf-engine/alf → alf}/engine.rb +0 -2
- data/lib/{alf-engine/alf → alf}/engine/aggregate.rb +6 -2
- data/lib/{alf-engine/alf → alf}/engine/autonum.rb +6 -2
- data/lib/{alf-engine/alf → alf}/engine/clip.rb +10 -2
- data/lib/{alf-engine/alf → alf}/engine/coerce.rb +6 -2
- data/lib/alf/engine/cog.rb +58 -0
- data/lib/{alf-engine/alf → alf}/engine/compact.rb +2 -2
- data/lib/{alf-engine/alf → alf}/engine/compact/set.rb +2 -2
- data/lib/{alf-engine/alf → alf}/engine/compact/uniq.rb +2 -2
- data/lib/{alf-engine/alf → alf}/engine/concat.rb +2 -2
- data/lib/{alf-engine/alf → alf}/engine/defaults.rb +6 -2
- data/lib/{alf-engine/alf → alf}/engine/filter.rb +8 -4
- data/lib/{alf-engine/alf → alf}/engine/generator.rb +6 -2
- data/lib/alf/engine/group.rb +7 -0
- data/lib/{alf-engine/alf → alf}/engine/group/hash.rb +11 -2
- data/lib/{alf-engine/alf → alf}/engine/hierarchize.rb +6 -2
- data/lib/{alf-engine/alf → alf}/engine/infer_heading.rb +2 -2
- data/lib/{alf-engine/alf → alf}/engine/join.rb +0 -0
- data/lib/{alf-engine/alf → alf}/engine/join/hash.rb +2 -2
- data/lib/{alf-engine/alf → alf}/engine/leaf.rb +7 -3
- data/lib/{alf-engine/alf → alf}/engine/materialize.rb +5 -1
- data/lib/{alf-engine/alf → alf}/engine/materialize/array.rb +3 -2
- data/lib/{alf-engine/alf → alf}/engine/materialize/hash.rb +3 -2
- data/lib/alf/engine/quota.rb +7 -0
- data/lib/{alf-engine/alf → alf}/engine/quota/cesure.rb +8 -3
- data/lib/alf/engine/rank.rb +7 -0
- data/lib/{alf-engine/alf → alf}/engine/rank/cesure.rb +8 -3
- data/lib/{alf-engine/alf → alf}/engine/rename.rb +6 -2
- data/lib/alf/engine/semi.rb +7 -0
- data/lib/{alf-engine/alf → alf}/engine/semi/hash.rb +7 -2
- data/lib/{alf-engine/alf → alf}/engine/set_attr.rb +8 -4
- data/lib/alf/engine/sort.rb +13 -0
- data/lib/{alf-engine/alf → alf}/engine/sort/in_memory.rb +12 -2
- data/lib/alf/engine/summarize.rb +13 -0
- data/lib/{alf-engine/alf → alf}/engine/summarize/cesure.rb +5 -4
- data/lib/{alf-engine/alf → alf}/engine/summarize/hash.rb +3 -2
- data/lib/{alf-engine/alf → alf}/engine/support/cesure.rb +0 -0
- data/lib/{alf-engine/alf → alf}/engine/take.rb +6 -2
- data/lib/{alf-engine/alf → alf}/engine/to_array.rb +13 -5
- data/lib/{alf-engine/alf → alf}/engine/type_safe.rb +2 -2
- data/lib/{alf-engine/alf → alf}/engine/ungroup.rb +7 -2
- data/lib/{alf-engine/alf → alf}/engine/unwrap.rb +11 -5
- data/lib/{alf-engine/alf → alf}/engine/wrap.rb +6 -2
- data/lib/{alf-core → alf}/errors.rb +2 -3
- data/lib/{alf-core → alf}/ext.rb +0 -0
- data/lib/{alf-core → alf}/ext/domain/heading_based.rb +5 -0
- data/lib/alf/facade.rb +53 -0
- data/lib/{alf-lang/alf → alf}/lang.rb +1 -1
- data/lib/{alf-lang/alf → alf}/lang/functional.rb +0 -4
- data/lib/{alf-lang/alf → alf}/lang/object_oriented.rb +0 -0
- data/lib/{alf-lang/alf → alf}/lang/oo/aggregation_methods.rb +1 -1
- data/lib/{alf-lang/alf → alf}/lang/oo/algebra_methods.rb +0 -12
- data/lib/{alf-lang/alf → alf}/lang/oo/rendering_methods.rb +1 -1
- data/lib/alf/lang/parser.rb +9 -0
- data/lib/alf/lang/parser/lispy.rb +63 -0
- data/lib/alf/lang/parser/safer.rb +69 -0
- data/lib/{alf-lang/alf → alf}/lang/predicates.rb +1 -1
- data/lib/{alf-optimizer/alf → alf}/optimizer.rb +15 -7
- data/lib/alf/optimizer/project.rb +182 -0
- data/lib/{alf-optimizer/alf → alf}/optimizer/restrict.rb +48 -50
- data/lib/{alf-predicate/alf → alf}/predicate.rb +16 -12
- data/lib/{alf-predicate/alf → alf}/predicate/factory.rb +13 -8
- data/lib/{alf-predicate/alf → alf}/predicate/grammar.rb +2 -5
- data/lib/{alf-predicate/alf → alf}/predicate/grammar.sexp.yml +11 -7
- data/lib/{alf-predicate/alf → alf}/predicate/nodes/and.rb +0 -0
- data/lib/{alf-predicate/alf → alf}/predicate/nodes/contradiction.rb +0 -0
- data/lib/{alf-predicate/alf → alf}/predicate/nodes/dyadic_comp.rb +0 -0
- data/lib/{alf-predicate/alf → alf}/predicate/nodes/eq.rb +0 -0
- data/lib/{alf-predicate/alf → alf}/predicate/nodes/expr.rb +10 -5
- data/lib/{alf-predicate/alf → alf}/predicate/nodes/gt.rb +0 -0
- data/lib/{alf-predicate/alf → alf}/predicate/nodes/gte.rb +0 -0
- data/lib/{alf-predicate/alf/predicate/nodes/var_ref.rb → alf/predicate/nodes/identifier.rb} +3 -3
- data/lib/{alf-predicate/alf → alf}/predicate/nodes/in.rb +2 -2
- data/lib/{alf-predicate/alf → alf}/predicate/nodes/literal.rb +0 -0
- data/lib/{alf-predicate/alf → alf}/predicate/nodes/lt.rb +0 -0
- data/lib/{alf-predicate/alf → alf}/predicate/nodes/lte.rb +0 -0
- data/lib/{alf-predicate/alf → alf}/predicate/nodes/nadic_bool.rb +0 -0
- data/lib/alf/predicate/nodes/native.rb +32 -0
- data/lib/{alf-predicate/alf → alf}/predicate/nodes/neq.rb +0 -0
- data/lib/{alf-predicate/alf → alf}/predicate/nodes/not.rb +0 -0
- data/lib/{alf-predicate/alf → alf}/predicate/nodes/or.rb +0 -0
- data/lib/{alf-predicate/alf/predicate/nodes/native.rb → alf/predicate/nodes/qualified_identifier.rb} +8 -4
- data/lib/{alf-predicate/alf → alf}/predicate/nodes/tautology.rb +0 -0
- data/lib/alf/predicate/processors.rb +3 -0
- data/lib/alf/predicate/processors/qualifier.rb +25 -0
- data/lib/alf/predicate/processors/renamer.rb +27 -0
- data/lib/{alf-predicate/alf → alf}/predicate/processors/to_ruby_code.rb +6 -11
- data/lib/{alf-io/alf → alf}/reader.rb +11 -2
- data/lib/{alf-io/alf → alf}/reader/csv.rb +0 -0
- data/lib/{alf-io/alf → alf}/reader/json.rb +0 -0
- data/lib/{alf-io/alf → alf}/reader/rash.rb +0 -0
- data/lib/{alf-io/alf → alf}/reader/ruby.rb +0 -0
- data/lib/alf/reader/yaml.rb +25 -0
- data/lib/{alf-relation/alf → alf}/relation.rb +12 -2
- data/lib/{alf-relvar/alf → alf}/relvar.rb +14 -21
- data/lib/alf/relvar/base.rb +35 -0
- data/lib/{alf-relvar/alf → alf}/relvar/fake.rb +3 -2
- data/lib/{alf-relvar/alf → alf}/relvar/read_only.rb +6 -30
- data/lib/{alf-relvar/alf → alf}/relvar/virtual.rb +0 -31
- data/lib/{alf-io/alf → alf}/renderer.rb +0 -0
- data/lib/{alf-io/alf → alf}/renderer/csv.rb +0 -0
- data/lib/{alf-io/alf → alf}/renderer/json.rb +0 -0
- data/lib/{alf-io/alf → alf}/renderer/rash.rb +0 -0
- data/lib/{alf-io/alf → alf}/renderer/text.rb +0 -0
- data/lib/{alf-io/alf → alf}/renderer/yaml.rb +2 -2
- data/lib/{alf-support/alf → alf}/support.rb +2 -1
- data/lib/{alf-support/alf → alf}/support/coerce.rb +0 -0
- data/lib/{alf-support/alf → alf}/support/config.rb +0 -0
- data/lib/{alf-io/alf → alf}/support/csv_utils.rb +0 -0
- data/lib/{alf-support/alf → alf}/support/dot_utils.rb +0 -0
- data/lib/{alf-support/alf → alf}/support/miscellaneous.rb +0 -0
- data/lib/{alf-support/alf → alf}/support/ordered_set.rb +0 -0
- data/lib/{alf-support/alf → alf}/support/registry.rb +0 -0
- data/lib/{alf-support/alf → alf}/support/scope.rb +0 -0
- data/lib/{alf-support/alf → alf}/support/to_lispy.rb +6 -1
- data/lib/{alf-support/alf → alf}/support/to_ruby_literal.rb +0 -0
- data/lib/alf/support/tree.rb +51 -0
- data/lib/{alf-support/alf → alf}/support/tuple_scope.rb +9 -1
- data/lib/{alf-relation/alf → alf}/tuple.rb +1 -1
- data/lib/{alf-types/alf → alf}/types.rb +0 -0
- data/lib/{alf-types/alf → alf}/types/attr_list.rb +2 -2
- data/lib/{alf-types/alf → alf}/types/attr_name.rb +0 -0
- data/lib/{alf-types/alf → alf}/types/boolean.rb +0 -0
- data/lib/{alf-types/alf → alf}/types/heading.rb +0 -0
- data/lib/{alf-types/alf → alf}/types/keys.rb +0 -0
- data/lib/{alf-types/alf → alf}/types/ordering.rb +7 -1
- data/lib/{alf-types/alf → alf}/types/renaming.rb +0 -0
- data/lib/{alf-types/alf → alf}/types/selection.rb +0 -0
- data/lib/{alf-types/alf → alf}/types/selector.rb +0 -0
- data/lib/{alf-types/alf → alf}/types/size.rb +0 -0
- data/lib/{alf-types/alf → alf}/types/summarization.rb +0 -0
- data/lib/{alf-types/alf → alf}/types/tuple_computation.rb +13 -4
- data/lib/{alf-types/alf → alf}/types/tuple_expression.rb +6 -19
- data/lib/{alf-types/alf → alf}/types/type_check.rb +1 -0
- data/lib/{alf-update/alf → alf}/update.rb +0 -0
- data/lib/{alf-update/alf → alf}/update/deleter.rb +0 -3
- data/lib/{alf-update/alf → alf}/update/inserter.rb +1 -7
- data/lib/{alf-update/alf → alf}/update/updater.rb +0 -2
- data/lib/{alf-viewpoint/alf → alf}/viewpoint.rb +9 -7
- data/lib/{alf-viewpoint/alf → alf}/viewpoint/metadata.rb +5 -2
- data/spec/compiler_helper.rb +20 -0
- data/spec/integration/relation/test_to_array.rb +6 -6
- data/spec/integration/test_examples.rb +14 -6
- data/spec/shared/a_cog.rb +8 -4
- data/spec/shared/a_valid_type_implementation.rb +4 -7
- data/spec/spec_helper.rb +9 -5
- data/spec/type_check_helper.rb +1 -0
- data/spec/unit/alf-adapter/shared_examples/an_adapter_with_readable_cogs.rb +1 -1
- data/spec/unit/alf-aggregator/test_concat.rb +8 -0
- data/spec/unit/alf-algebra/operand/named/test_hash_and_equal.rb +53 -0
- data/spec/unit/alf-algebra/operand/named/test_keys.rb +1 -1
- data/spec/unit/alf-algebra/operand/named/test_to_ascii_tree.rb +18 -0
- data/spec/unit/alf-algebra/operand/named/test_to_cog.rb +24 -0
- data/spec/unit/alf-algebra/operand/named/test_to_relvar.rb +1 -1
- data/spec/unit/alf-algebra/operand/named/test_type_check.rb +38 -0
- data/spec/unit/alf-algebra/operand/proxy/test_to_cog.rb +42 -0
- data/spec/unit/alf-algebra/operand/test_coerce.rb +0 -6
- data/spec/unit/alf-algebra/operand/test_proxy.rb +1 -1
- data/spec/unit/alf-algebra/operator/allbut/test_key_preserving.rb +1 -1
- data/spec/unit/alf-algebra/operator/allbut/test_keys.rb +1 -1
- data/spec/unit/alf-algebra/operator/allbut/test_type_check.rb +42 -0
- data/spec/unit/alf-algebra/operator/autonum/test_type_check.rb +30 -0
- data/spec/unit/alf-algebra/operator/clip/test_type_check.rb +42 -0
- data/spec/unit/alf-algebra/operator/coerce/test_type_check.rb +42 -0
- data/spec/unit/alf-algebra/operator/commons/test_resulting_type.rb +20 -0
- data/spec/unit/alf-algebra/operator/commons/test_to_ascii_tree.rb +40 -0
- data/spec/unit/alf-algebra/operator/extend/test_type_check.rb +42 -0
- data/spec/unit/alf-algebra/operator/frame/test_type_check.rb +54 -0
- data/spec/unit/alf-algebra/operator/group/test_type_check.rb +50 -0
- data/spec/unit/alf-algebra/operator/hierarchize/test_type_check.rb +54 -0
- data/spec/unit/alf-algebra/operator/intersect/test_type_check.rb +30 -0
- data/spec/unit/alf-algebra/operator/join/test_type_check.rb +62 -0
- data/spec/unit/alf-algebra/operator/matching/test_keys.rb +1 -1
- data/spec/unit/alf-algebra/operator/matching/test_type_check.rb +62 -0
- data/spec/unit/alf-algebra/operator/minus/test_type_check.rb +30 -0
- data/spec/unit/alf-algebra/operator/not_matching/test_type_check.rb +62 -0
- data/spec/unit/alf-algebra/operator/page/test_type_check.rb +50 -0
- data/spec/unit/alf-algebra/operator/project/test_type_check.rb +42 -0
- data/spec/unit/alf-algebra/operator/quota/test_type_check.rb +54 -0
- data/spec/unit/alf-algebra/operator/rank/test_type_check.rb +42 -0
- data/spec/unit/alf-algebra/operator/rename/test_type_check.rb +42 -0
- data/spec/unit/alf-algebra/operator/restrict/test_type_check.rb +46 -0
- data/spec/unit/alf-algebra/operator/shared/test_to_cog.rb +34 -0
- data/spec/unit/alf-algebra/operator/sort/test_type_check.rb +30 -0
- data/spec/unit/alf-algebra/operator/summarize/test_type_check.rb +42 -0
- data/spec/unit/alf-algebra/operator/test_hash_and_equal.rb +59 -0
- data/spec/unit/alf-algebra/operator/ungroup/test_type_check.rb +44 -0
- data/spec/unit/alf-algebra/operator/union/test_type_check.rb +30 -0
- data/spec/unit/alf-algebra/operator/unwrap/test_type_check.rb +44 -0
- data/spec/unit/alf-algebra/operator/wrap/test_type_check.rb +50 -0
- data/spec/unit/alf-algebra/support/signature/test_to_lispy.rb +24 -9
- data/spec/unit/alf-algebra/support/test_non_relational.rb +1 -2
- data/spec/unit/alf-algebra/support/test_relational.rb +1 -1
- data/spec/unit/alf-compiler/default/test_allbut.rb +65 -0
- data/spec/unit/alf-compiler/default/test_autonum.rb +30 -0
- data/spec/unit/alf-compiler/default/test_clip.rb +30 -0
- data/spec/unit/alf-compiler/default/test_coerce.rb +30 -0
- data/spec/unit/alf-compiler/default/test_compact.rb +26 -0
- data/spec/unit/alf-compiler/default/test_completude.rb +16 -0
- data/spec/unit/alf-compiler/default/test_defaults.rb +50 -0
- data/spec/unit/alf-compiler/default/test_extend.rb +34 -0
- data/spec/unit/alf-compiler/default/test_frame.rb +77 -0
- data/spec/unit/alf-compiler/default/test_generator.rb +30 -0
- data/spec/unit/alf-compiler/default/test_group.rb +38 -0
- data/spec/unit/alf-compiler/default/test_hierarchize.rb +40 -0
- data/spec/unit/alf-compiler/default/test_intersect.rb +34 -0
- data/spec/unit/alf-compiler/default/test_join.rb +34 -0
- data/spec/unit/alf-compiler/default/test_matching.rb +38 -0
- data/spec/unit/alf-compiler/default/test_minus.rb +38 -0
- data/spec/unit/alf-compiler/default/test_not_matching.rb +38 -0
- data/spec/unit/alf-compiler/default/test_page.rb +91 -0
- data/spec/unit/alf-compiler/default/test_project.rb +76 -0
- data/spec/unit/alf-compiler/default/test_quota.rb +88 -0
- data/spec/unit/alf-compiler/default/test_rank.rb +71 -0
- data/spec/unit/alf-compiler/default/test_rename.rb +30 -0
- data/spec/unit/alf-compiler/default/test_restrict.rb +34 -0
- data/spec/unit/alf-compiler/default/test_sort.rb +81 -0
- data/spec/unit/alf-compiler/default/test_summarize.rb +85 -0
- data/spec/unit/alf-compiler/default/test_ungroup.rb +30 -0
- data/spec/unit/alf-compiler/default/test_union.rb +36 -0
- data/spec/unit/alf-compiler/default/test_unwrap.rb +30 -0
- data/spec/unit/alf-compiler/default/test_wrap.rb +38 -0
- data/spec/unit/alf-compiler/shared/compiled_examples.rb +111 -0
- data/spec/unit/alf-compiler/test_principle.rb +332 -0
- data/spec/unit/alf-core/test_aggregator.rb +0 -24
- data/spec/unit/alf-database/connection/test_parse.rb +0 -49
- data/spec/unit/alf-database/connection/test_relvar.rb +1 -9
- data/spec/unit/alf-database/options/test_parser.rb +23 -0
- data/spec/unit/alf-engine/cog/test_to_ascii_tree.rb +14 -0
- data/spec/unit/alf-engine/test_aggregate.rb +2 -2
- data/spec/unit/alf-engine/test_filter.rb +1 -1
- data/spec/unit/alf-engine/test_to_array.rb +16 -2
- data/spec/unit/alf-io/reader/test_yaml.rb +30 -0
- data/spec/unit/alf-io/renderer/test_yaml.rb +11 -0
- data/spec/unit/alf-lang/functional/test_aggregation.rb +18 -4
- data/spec/unit/alf-lang/parser/lispy/test_connection_bang.rb +28 -0
- data/spec/unit/alf-lang/parser/lispy/test_parse.rb +38 -0
- data/spec/unit/alf-lang/parser/lispy/test_to_s.rb +16 -0
- data/spec/unit/alf-lang/parser/safer/safe.txt +5 -0
- data/spec/unit/alf-lang/parser/safer/test_parse.rb +82 -0
- data/spec/unit/alf-lang/parser/safer/unsafe.txt +14 -0
- data/spec/unit/alf-optimizer/restrict/test_on_autonum.rb +1 -1
- data/spec/unit/alf-optimizer/test_quota.rb +1 -1
- data/spec/unit/alf-optimizer/test_rename.rb +7 -0
- data/spec/unit/alf-optimizer/test_summarize.rb +1 -1
- data/spec/unit/alf-predicate/expr/test_to_proc.rb +4 -6
- data/spec/unit/alf-predicate/expr/test_to_ruby_code.rb +23 -23
- data/spec/unit/alf-predicate/factory/shared/a_comparison_factory_method.rb +3 -3
- data/spec/unit/alf-predicate/factory/test_between.rb +1 -1
- data/spec/unit/alf-predicate/factory/test_comp.rb +3 -3
- data/spec/unit/alf-predicate/factory/test_factor_predicate.rb +3 -3
- data/spec/unit/alf-predicate/factory/{test_var_ref.rb → test_identifier.rb} +4 -4
- data/spec/unit/alf-predicate/factory/test_in.rb +1 -1
- data/spec/unit/alf-predicate/factory/test_native.rb +9 -4
- data/spec/unit/alf-predicate/factory/test_qualified_identifier.rb +17 -0
- data/spec/unit/alf-predicate/grammar/test_match.rb +9 -9
- data/spec/unit/alf-predicate/grammar/test_sexpr.rb +11 -11
- data/spec/unit/alf-predicate/nodes/{var_ref → identifier}/test_and_split.rb +2 -2
- data/spec/unit/alf-predicate/nodes/{var_ref → identifier}/test_free_variables.rb +2 -2
- data/spec/unit/alf-predicate/nodes/identifier/test_name.rb +14 -0
- data/spec/unit/alf-predicate/nodes/qualified_identifier/test_and_split.rb +25 -0
- data/spec/unit/alf-predicate/nodes/qualified_identifier/test_free_variables.rb +14 -0
- data/spec/unit/alf-predicate/nodes/qualified_identifier/test_name.rb +14 -0
- data/spec/unit/alf-predicate/nodes/qualified_identifier/test_qualifier.rb +14 -0
- data/spec/unit/alf-predicate/predicate/test_and_split.rb +4 -4
- data/spec/unit/alf-predicate/predicate/test_bool_and.rb +1 -1
- data/spec/unit/alf-predicate/predicate/test_bool_not.rb +1 -1
- data/spec/unit/alf-predicate/predicate/test_bool_or.rb +1 -1
- data/spec/unit/alf-predicate/predicate/test_coerce.rb +9 -8
- data/spec/unit/alf-predicate/predicate/test_contradiction.rb +2 -2
- data/spec/unit/alf-predicate/predicate/test_factory_methods.rb +12 -12
- data/spec/unit/alf-predicate/predicate/test_qualify.rb +36 -0
- data/spec/unit/alf-predicate/predicate/test_rename.rb +58 -15
- data/spec/unit/alf-predicate/predicate/test_tautology.rb +2 -2
- data/spec/unit/alf-predicate/predicate/test_to_ruby_code.rb +8 -2
- data/spec/unit/alf-predicate/predicate/test_to_ruby_literal.rb +1 -1
- data/spec/unit/alf-predicate/test_predicate.rb +7 -8
- data/spec/unit/alf-relation/relation/class/test_dum.rb +19 -0
- data/spec/unit/alf-relation/relation/test_heading.rb +1 -1
- data/spec/unit/alf-relation/relation/test_keys.rb +17 -0
- data/spec/unit/alf-relation/relation/test_relation.rb +1 -1
- data/spec/unit/alf-relation/relation/test_to_a.rb +10 -10
- data/spec/unit/alf-relvar/base/test_oo_lang.rb +26 -10
- data/spec/unit/alf-relvar/base/test_to_cog.rb +2 -2
- data/spec/unit/alf-relvar/read_only/test_to_relation.rb +17 -0
- data/spec/unit/alf-relvar/read_only/test_type.rb +0 -4
- data/spec/unit/alf-relvar/virtual/test_oo_lang.rb +0 -4
- data/spec/unit/alf-relvar/virtual/test_to_cog.rb +4 -4
- data/spec/unit/alf-relvar/virtual/test_to_s.rb +1 -1
- data/spec/unit/alf-support/test_to_lispy.rb +13 -31
- data/spec/unit/alf-support/test_tuple_scope.rb +11 -0
- data/spec/unit/alf-types/ordering/test_coerce.rb +13 -0
- data/spec/unit/alf-types/ordering/test_lte.rb +43 -0
- data/spec/unit/alf-types/summarization/test_coerce.rb +2 -2
- data/spec/unit/alf-types/summarization/test_least.rb +1 -1
- data/spec/unit/alf-types/summarization/test_summarize.rb +1 -1
- data/spec/unit/alf-types/test_summarization.rb +2 -2
- data/spec/unit/alf-types/test_tuple_expression.rb +2 -2
- data/spec/unit/alf-types/tuple_computation/test_coerce.rb +4 -13
- data/spec/unit/alf-types/tuple_computation/test_empty.rb +24 -0
- data/spec/unit/alf-types/tuple_computation/test_project.rb +46 -0
- data/spec/unit/alf-types/tuple_expression/test_coerce.rb +1 -10
- data/spec/unit/alf-types/tuple_expression/test_evaluate.rb +0 -8
- data/spec/unit/alf-types/tuple_expression/test_to_ruby_literal.rb +0 -5
- data/spec/unit/alf-update/deleter/{test_var_ref.rb → test_identifier.rb} +1 -1
- data/spec/unit/alf-update/inserter/{test_var_ref.rb → test_identifier.rb} +1 -1
- data/spec/unit/alf-update/updater/{test_var_ref.rb → test_identifier.rb} +1 -1
- data/spec/unit/alf-viewpoint/test_native_const.rb +1 -1
- data/spec/update_helper.rb +18 -2
- metadata +417 -313
- data/lib/alf-algebra/alf/algebra/operand/named.rb +0 -36
- data/lib/alf-algebra/alf/algebra/operator/infer_heading.rb +0 -19
- data/lib/alf-algebra/alf/algebra/operator/type_safe.rb +0 -21
- data/lib/alf-algebra/alf/algebra/support/to_dot.rb +0 -196
- data/lib/alf-core/facade.rb +0 -39
- data/lib/alf-engine/alf/engine/cog.rb +0 -50
- data/lib/alf-engine/alf/engine/compiler.rb +0 -171
- data/lib/alf-engine/alf/engine/group.rb +0 -3
- data/lib/alf-engine/alf/engine/quota.rb +0 -3
- data/lib/alf-engine/alf/engine/rank.rb +0 -3
- data/lib/alf-engine/alf/engine/semi.rb +0 -3
- data/lib/alf-engine/alf/engine/sort.rb +0 -30
- data/lib/alf-engine/alf/engine/summarize.rb +0 -4
- data/lib/alf-engine/alf/engine/to_dot.rb +0 -60
- data/lib/alf-io/alf/io.rb +0 -6
- data/lib/alf-lang/alf/lang/lispy.rb +0 -65
- data/lib/alf-predicate/alf/predicate/parser.rb +0 -12
- data/lib/alf-predicate/alf/predicate/processors.rb +0 -3
- data/lib/alf-predicate/alf/predicate/processors/renamer.rb +0 -19
- data/lib/alf-predicate/alf/predicate/processors/to_proc.rb +0 -35
- data/lib/alf-relvar/alf/relvar/base.rb +0 -69
- data/lib/alf-support/alf/support/bindable.rb +0 -26
- data/spec/integration/algebra/test_to_dot.rb +0 -14
- data/spec/integration/relvar/test_type_safe.rb +0 -22
- data/spec/unit/alf-algebra/operator/infer_heading/test_keys.rb +0 -23
- data/spec/unit/alf-algebra/operator/test_infer_heading.rb +0 -16
- data/spec/unit/alf-algebra/operator/type_safe/test_heading.rb +0 -26
- data/spec/unit/alf-algebra/operator/type_safe/test_keys.rb +0 -26
- data/spec/unit/alf-engine/compiler/test_on_frame.rb +0 -70
- data/spec/unit/alf-engine/compiler/test_on_hierarchize.rb +0 -33
- data/spec/unit/alf-engine/compiler/test_on_page.rb +0 -128
- data/spec/unit/alf-engine/compiler/test_unsupported.rb +0 -48
- data/spec/unit/alf-lang/lispy/test_connection_bang.rb +0 -26
- data/spec/unit/alf-lang/lispy/test_parse.rb +0 -38
- data/spec/unit/alf-lang/lispy/test_to_s.rb +0 -14
- data/spec/unit/alf-optimizer/optimizer/test_optimizer.rb +0 -37
- data/spec/unit/alf-optimizer/test_infer_heading.rb +0 -9
- data/spec/unit/alf-predicate/grammar/test_parse.rb +0 -23
- data/spec/unit/alf-predicate/nodes/var_ref/test_var_name.rb +0 -14
- data/spec/unit/alf-relvar/base/test_name.rb +0 -15
- data/spec/unit/alf-relvar/virtual/test_connection.rb +0 -15
- data/spec/unit/alf-support/bindable/test_bind.rb +0 -60
- data/spec/unit/alf-support/bindable/test_bound.rb +0 -31
- data/spec/unit/alf-support/bindable/test_connection.rb +0 -31
- data/spec/unit/alf-support/bindable/test_connection_bang.rb +0 -35
- data/spec/unit/alf-update/inserter/test_type_safe.rb +0 -72
@@ -0,0 +1,332 @@
|
|
1
|
+
require 'compiler_helper'
|
2
|
+
module Alf
|
3
|
+
describe Compiler, "the overall principle" do
|
4
|
+
|
5
|
+
# This is a compiler dedicated to specific adapters, e.g. SQL
|
6
|
+
class DedicatedCompiler < Compiler
|
7
|
+
|
8
|
+
def supports_reuse?
|
9
|
+
true
|
10
|
+
end
|
11
|
+
|
12
|
+
def reuse(plan, compiled)
|
13
|
+
compiled
|
14
|
+
end
|
15
|
+
|
16
|
+
def on_project(plan, expr, compiled)
|
17
|
+
DedicatedCog.new(expr, self, [compiled])
|
18
|
+
end
|
19
|
+
|
20
|
+
def on_sort(plan, expr, compiled)
|
21
|
+
Engine::Sort.new(compiled, expr.ordering)
|
22
|
+
end
|
23
|
+
|
24
|
+
def on_page(plan, expr, compiled)
|
25
|
+
compiled = plan.recompile(compiled){|p|
|
26
|
+
p.sort(expr.operand, expr.ordering)
|
27
|
+
}
|
28
|
+
DedicatedCog.new(expr, self, [compiled])
|
29
|
+
end
|
30
|
+
|
31
|
+
def on_ungroup(plan, expr, compiled)
|
32
|
+
raise NotSupportedError
|
33
|
+
end
|
34
|
+
|
35
|
+
def on_union(plan, expr, left, right)
|
36
|
+
DedicatedCog.new(expr, self, [left, right])
|
37
|
+
end
|
38
|
+
|
39
|
+
end # class DedicatedCompiler
|
40
|
+
|
41
|
+
# This is the class supposed to be served by an adapter.
|
42
|
+
# It returns self on to_cog and has the dedicated compiler.
|
43
|
+
class DedicatedCog
|
44
|
+
include Engine::Cog
|
45
|
+
|
46
|
+
def initialize(expr, compiler, operands = nil)
|
47
|
+
super(expr, compiler)
|
48
|
+
@operands = operands
|
49
|
+
end
|
50
|
+
attr_reader :operands
|
51
|
+
|
52
|
+
def left
|
53
|
+
unless operands && operands.size == 2
|
54
|
+
raise "Unexpected operands `#{operands.inspect}`"
|
55
|
+
end
|
56
|
+
operands.first
|
57
|
+
end
|
58
|
+
|
59
|
+
def right
|
60
|
+
unless operands && operands.size == 2
|
61
|
+
raise "Unexpected operands `#{operands.inspect}`"
|
62
|
+
end
|
63
|
+
operands.last
|
64
|
+
end
|
65
|
+
|
66
|
+
def operand
|
67
|
+
unless operands && operands.size == 1
|
68
|
+
raise "Unexpected operands `#{operands.inspect}`"
|
69
|
+
end
|
70
|
+
operands.first
|
71
|
+
end
|
72
|
+
|
73
|
+
end # class DedicatedCog
|
74
|
+
|
75
|
+
subject{ default.call(expr) }
|
76
|
+
|
77
|
+
let(:cog){
|
78
|
+
DedicatedCog.new(nil, dedicated)
|
79
|
+
}
|
80
|
+
|
81
|
+
let(:cog2){
|
82
|
+
DedicatedCog.new(nil, dedicated)
|
83
|
+
}
|
84
|
+
|
85
|
+
let(:default){
|
86
|
+
Compiler::Default.new
|
87
|
+
}
|
88
|
+
|
89
|
+
let(:dedicated){
|
90
|
+
DedicatedCompiler.new
|
91
|
+
}
|
92
|
+
|
93
|
+
context 'on a direct cog-proxied operand' do
|
94
|
+
# the first compiler takes care of compiling the stuff, by simple
|
95
|
+
# delegation to to_cog of the operand
|
96
|
+
|
97
|
+
let(:expr){
|
98
|
+
an_operand(cog)
|
99
|
+
}
|
100
|
+
|
101
|
+
it{ should be(cog) }
|
102
|
+
|
103
|
+
it 'should have expected compiler' do
|
104
|
+
subject.compiler.should be(dedicated)
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
context 'on a supported operator' do
|
109
|
+
# the first compiler compiles the leaf.
|
110
|
+
# the second compiler compiles the projection.
|
111
|
+
|
112
|
+
let(:expr){
|
113
|
+
project(an_operand(cog), [:a])
|
114
|
+
}
|
115
|
+
|
116
|
+
it{ should be_a(DedicatedCog) }
|
117
|
+
|
118
|
+
it 'should have correct expr' do
|
119
|
+
subject.expr.should be(expr)
|
120
|
+
end
|
121
|
+
|
122
|
+
it 'should have expected compiler' do
|
123
|
+
subject.compiler.should be(dedicated)
|
124
|
+
end
|
125
|
+
|
126
|
+
it 'should have correct operand' do
|
127
|
+
subject.operand.should be(cog)
|
128
|
+
subject.operand.compiler.should be(dedicated)
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
context 'on a dyadic supported operator' do
|
133
|
+
# the first compiler compiles both leafs.
|
134
|
+
# the second compiler compiles the union.
|
135
|
+
|
136
|
+
let(:expr){
|
137
|
+
union(an_operand(cog), an_operand(cog2))
|
138
|
+
}
|
139
|
+
|
140
|
+
it{ should be_a(DedicatedCog) }
|
141
|
+
|
142
|
+
it 'should have correct expr' do
|
143
|
+
subject.expr.should be(expr)
|
144
|
+
end
|
145
|
+
|
146
|
+
it 'should have correct operands' do
|
147
|
+
subject.operands.should eq([cog, cog2])
|
148
|
+
end
|
149
|
+
|
150
|
+
it 'should have expected compiler' do
|
151
|
+
subject.compiler.should be(dedicated)
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
context 'on an operator requiring compiling sub-expressions' do
|
156
|
+
|
157
|
+
let(:expr){
|
158
|
+
page(an_operand(cog), [:name, :asc], 2)
|
159
|
+
}
|
160
|
+
|
161
|
+
it{ should be_a(DedicatedCog) }
|
162
|
+
|
163
|
+
it 'has the sort as sub-cog' do
|
164
|
+
subject.operand.should be_a(Engine::Sort)
|
165
|
+
end
|
166
|
+
|
167
|
+
it 'has the cog as sub-sub operand' do
|
168
|
+
subject.operand.operand.should be(cog)
|
169
|
+
end
|
170
|
+
|
171
|
+
it 'should have expected compiler' do
|
172
|
+
subject.compiler.should be(dedicated)
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
context 'on an unsupported operator' do
|
177
|
+
# the first compiler compiles the leaf.
|
178
|
+
# the second compiler fails at compiling the projection.
|
179
|
+
# the first compiler compiles the projection.
|
180
|
+
|
181
|
+
let(:expr){
|
182
|
+
rename(an_operand(cog), :a => :b)
|
183
|
+
}
|
184
|
+
|
185
|
+
it{ should be_a(Engine::Rename) }
|
186
|
+
|
187
|
+
it 'should have the cog as operand' do
|
188
|
+
subject.operand.should be(cog)
|
189
|
+
end
|
190
|
+
|
191
|
+
it 'should have expected compiler' do
|
192
|
+
subject.compiler.should be(default)
|
193
|
+
end
|
194
|
+
end
|
195
|
+
|
196
|
+
context 'on a partly supported operator' do
|
197
|
+
# the first compiler compiles the leaf.
|
198
|
+
# the second compiler fails at compiling the unwrap and fallsback.
|
199
|
+
# the first compiler compiles the unwrap.
|
200
|
+
|
201
|
+
let(:expr){
|
202
|
+
unwrap(an_operand(cog), :a)
|
203
|
+
}
|
204
|
+
|
205
|
+
it{ should be_a(Engine::Unwrap) }
|
206
|
+
|
207
|
+
it 'should have the cog as operand' do
|
208
|
+
subject.operand.should be(cog)
|
209
|
+
end
|
210
|
+
|
211
|
+
it 'should have expected compilers' do
|
212
|
+
subject.compiler.should be(default)
|
213
|
+
end
|
214
|
+
end
|
215
|
+
|
216
|
+
context 'on a partly supported operator through a NotSupportedError' do
|
217
|
+
# the first compiler compiles the leaf.
|
218
|
+
# the second compiler fails at compiling the ungroup and fallsback.
|
219
|
+
# the first compiler compiles the ungroup.
|
220
|
+
|
221
|
+
let(:expr){
|
222
|
+
ungroup(an_operand(cog), :a)
|
223
|
+
}
|
224
|
+
|
225
|
+
it{ should be_a(Engine::Ungroup) }
|
226
|
+
|
227
|
+
it 'should have the cog as operand' do
|
228
|
+
subject.operand.should be(cog)
|
229
|
+
end
|
230
|
+
|
231
|
+
it 'should have expected compilers' do
|
232
|
+
subject.compiler.should be(default)
|
233
|
+
end
|
234
|
+
end
|
235
|
+
|
236
|
+
context 'on a doubly supported operator' do
|
237
|
+
# the first compiler compiles the leaf.
|
238
|
+
# the second compiler compiles the first projection.
|
239
|
+
# the second compiler compiles the second projection.
|
240
|
+
|
241
|
+
let(:subexpr){
|
242
|
+
project(an_operand(cog), [:a])
|
243
|
+
}
|
244
|
+
|
245
|
+
let(:expr){
|
246
|
+
project(subexpr)
|
247
|
+
}
|
248
|
+
|
249
|
+
it{ should be_a(DedicatedCog) }
|
250
|
+
|
251
|
+
it 'should have correct traceability' do
|
252
|
+
subject.expr.should be(expr)
|
253
|
+
end
|
254
|
+
|
255
|
+
it 'should have expected compiler' do
|
256
|
+
subject.compiler.should be(dedicated)
|
257
|
+
end
|
258
|
+
|
259
|
+
it 'should have correct sub-cog' do
|
260
|
+
subject.operand.should be_a(DedicatedCog)
|
261
|
+
subject.operand.expr.should be(subexpr)
|
262
|
+
subject.operand.compiler.should be(dedicated)
|
263
|
+
end
|
264
|
+
|
265
|
+
it 'should have correct sub-sub-cog' do
|
266
|
+
subject.operand.operand.should be(cog)
|
267
|
+
subject.operand.operand.compiler.should be(dedicated)
|
268
|
+
end
|
269
|
+
end
|
270
|
+
|
271
|
+
context 'on a dyadic operator compiled by two different compilers' do
|
272
|
+
# the first compiler compiles the left leaf and the projection.
|
273
|
+
# the second compiler compiles the right leaf and the projection.
|
274
|
+
# the this compiler compiles the union.
|
275
|
+
|
276
|
+
let(:expr){
|
277
|
+
join(project(an_operand(left), [:a]), project(an_operand(right), [:a]))
|
278
|
+
}
|
279
|
+
|
280
|
+
let(:compilo1){
|
281
|
+
DedicatedCompiler.new
|
282
|
+
}
|
283
|
+
|
284
|
+
let(:compilo2){
|
285
|
+
DedicatedCompiler.new
|
286
|
+
}
|
287
|
+
|
288
|
+
let(:left){
|
289
|
+
DedicatedCog.new(nil, compilo1)
|
290
|
+
}
|
291
|
+
|
292
|
+
let(:right){
|
293
|
+
DedicatedCog.new(nil, compilo2)
|
294
|
+
}
|
295
|
+
|
296
|
+
let(:default){
|
297
|
+
Compiler::Default.new
|
298
|
+
}
|
299
|
+
|
300
|
+
it{ should be_a(Engine::Join) }
|
301
|
+
|
302
|
+
it 'should have correct expr' do
|
303
|
+
subject.expr.should be(expr)
|
304
|
+
end
|
305
|
+
|
306
|
+
it 'should have correct sub-cogs' do
|
307
|
+
subject.left.should be_a(DedicatedCog)
|
308
|
+
subject.right.should be_a(DedicatedCog)
|
309
|
+
end
|
310
|
+
|
311
|
+
it 'should have expected compilers' do
|
312
|
+
subject.compiler.should be(default)
|
313
|
+
subject.left.compiler.should be(compilo1)
|
314
|
+
subject.right.compiler.should be(compilo2)
|
315
|
+
end
|
316
|
+
end
|
317
|
+
|
318
|
+
context 'on expressions where reuse is possible' do
|
319
|
+
let(:expr){
|
320
|
+
reused = project(an_operand(cog), [:a])
|
321
|
+
union(reused, reused)
|
322
|
+
}
|
323
|
+
|
324
|
+
it{ should be_a(DedicatedCog) }
|
325
|
+
|
326
|
+
it 'should reuse the compilation result' do
|
327
|
+
subject.left.should be(subject.right)
|
328
|
+
end
|
329
|
+
end
|
330
|
+
|
331
|
+
end
|
332
|
+
end
|
@@ -29,30 +29,6 @@ module Alf
|
|
29
29
|
let(:arg){ Aggregator.sum{a} }
|
30
30
|
it{ should eq(arg) }
|
31
31
|
end
|
32
|
-
|
33
|
-
describe "from a String" do
|
34
|
-
let(:arg){ "sum{a}" }
|
35
|
-
|
36
|
-
it {
|
37
|
-
should be_a(Aggregator::Sum)
|
38
|
-
}
|
39
|
-
|
40
|
-
it 'should have source code' do
|
41
|
-
subject.has_source_code!.should eq("sum{a}")
|
42
|
-
end
|
43
|
-
|
44
|
-
specify{
|
45
|
-
subject.aggregate(input).should eql(7)
|
46
|
-
}
|
47
|
-
|
48
|
-
end
|
49
|
-
|
50
|
-
end
|
51
|
-
|
52
|
-
it 'should implement optimistic equality based on source code' do
|
53
|
-
ag1 = Aggregator.coerce("sum{ qty }")
|
54
|
-
ag2 = Aggregator.coerce("sum{ qty }")
|
55
|
-
ag1.should eq(ag2)
|
56
32
|
end
|
57
33
|
|
58
34
|
end
|
@@ -5,26 +5,8 @@ module Alf
|
|
5
5
|
|
6
6
|
let(:conn){ sap_conn }
|
7
7
|
|
8
|
-
shared_examples_for 'a bound expression' do
|
9
|
-
|
10
|
-
it{ should be_bound }
|
11
|
-
|
12
|
-
it 'has the expected connection' do
|
13
|
-
subject.connection!.should be(conn)
|
14
|
-
end
|
15
|
-
|
16
|
-
it 'has bound operands too' do
|
17
|
-
subject.operands.all?{|op|
|
18
|
-
op.should be_bound
|
19
|
-
op.connection!.should be(conn)
|
20
|
-
} if subject.is_a?(Algebra::Operator)
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
8
|
shared_examples_for 'a named operand on suppliers' do
|
25
9
|
|
26
|
-
it_should_behave_like 'a bound expression'
|
27
|
-
|
28
10
|
it{ should be_a(Algebra::Operand::Named) }
|
29
11
|
|
30
12
|
it 'has the expected name' do
|
@@ -34,8 +16,6 @@ module Alf
|
|
34
16
|
|
35
17
|
shared_examples_for 'a join operand on suppliers and supplies' do
|
36
18
|
|
37
|
-
it_should_behave_like 'a bound expression'
|
38
|
-
|
39
19
|
it{ should be_a(Algebra::Join) }
|
40
20
|
end
|
41
21
|
|
@@ -58,19 +38,6 @@ module Alf
|
|
58
38
|
|
59
39
|
it_should_behave_like 'a named operand on suppliers'
|
60
40
|
end
|
61
|
-
|
62
|
-
context 'parsed from an existing operand' do
|
63
|
-
let(:expr){ Algebra.named_operand(:suppliers, 12) }
|
64
|
-
|
65
|
-
subject{ conn.parse(expr) }
|
66
|
-
|
67
|
-
it_should_behave_like 'a named operand on suppliers'
|
68
|
-
|
69
|
-
it 'does not touch the original expr' do
|
70
|
-
subject.should_not be(expr)
|
71
|
-
expr.connection.should eq(12)
|
72
|
-
end
|
73
|
-
end
|
74
41
|
end
|
75
42
|
|
76
43
|
context 'when a complex expression' do
|
@@ -86,22 +53,6 @@ module Alf
|
|
86
53
|
|
87
54
|
it_should_behave_like 'a join operand on suppliers and supplies'
|
88
55
|
end
|
89
|
-
|
90
|
-
context 'with an expression' do
|
91
|
-
let(:expr){
|
92
|
-
conn.parse{ join(project(suppliers, [:sid]), supplies) }.bind(12)
|
93
|
-
}
|
94
|
-
|
95
|
-
subject{ conn.parse(expr) }
|
96
|
-
|
97
|
-
it_should_behave_like 'a join operand on suppliers and supplies'
|
98
|
-
|
99
|
-
it 'does not touch the original expr' do
|
100
|
-
subject.should_not be(expr)
|
101
|
-
expr.connection.should eq(12)
|
102
|
-
expr.operands.all?{|op| op.connection.should eq(12) }
|
103
|
-
end
|
104
|
-
end
|
105
56
|
end
|
106
57
|
|
107
58
|
end
|
@@ -11,7 +11,7 @@ module Alf
|
|
11
11
|
it{ should be_a(Relvar::Base) }
|
12
12
|
|
13
13
|
it 'has the expected name' do
|
14
|
-
subject.name.should eq(:suppliers)
|
14
|
+
subject.expr.name.should eq(:suppliers)
|
15
15
|
end
|
16
16
|
|
17
17
|
it 'is bound to the serving connection' do
|
@@ -27,14 +27,6 @@ module Alf
|
|
27
27
|
it 'has the expected expression' do
|
28
28
|
subject.expr.should be_a(Algebra::Project)
|
29
29
|
end
|
30
|
-
|
31
|
-
it 'is bound to the serving connection' do
|
32
|
-
subject.connection!.should be(conn)
|
33
|
-
end
|
34
|
-
|
35
|
-
it 'has a bound expression as well' do
|
36
|
-
subject.expr.connection!.should be(conn)
|
37
|
-
end
|
38
30
|
end
|
39
31
|
|
40
32
|
end
|